I have a series of complex charts to draw, so I have written a macro that takes a set of instructions from a CSV file and draws them appropriately. This works, but I need to manually save the produced page as a .vsdx file (i.e. without my macro code) after the fact.
What I'd like to do is specify the filename in the input file and have it produce a macro-free visio file of that name.
I've tried
Application.ActiveDocument.SaveAs filename
but this immediately generates a run-time error: "VB projects cannot be saved in macro-free files".
I understand that - I don't want my macro code in each of the (dozens of) flow charts I'm drawing. How can I suppress this error?
Thanks in advance.
If you want to have your macro(s) stored in a document file, then you'd want to have your macro generate a new document in which you draw your complex charts. But as #y4cine commented, you need to keep your code separate from your content, if you want to save your content as macro-free files.
Otherwise you may be able to set Application.AlertResponse to whatever response Visio asks interactively when you try to save a file that has a macro as a macro-free format.
Related
I'm trying to access Outlook attachments from clipboard using VBA to further process the file.
The user copies an attachment to the clipboard (Right click -> Copy), opens PowerPoint, clicks a buttons and gets the presentation inserted a the end of the document.
The key part seems to access the PowerPoint file in the clipboard an save it on the file system.
Can someone help and provide a sample code for this using VBA in PowerPoint?
Many thanks!
I've found a way achieve it.
Getting filenames: Solution has been posted here: http://www.access-o-mania.de/forum/index.php?topic=17045.15
Getting the content
file size in clipboard can be obtained by GlobalSize(handle)
pointer the by GlobalLock(handle)
content using CopyMemory(destination, source, length)
Look at the clipboard contents with an app like ClipSpy. Since there is no physical file to be copied, the full file path is not included (no CF_HDROP format). But FileGroupDescriptor and FileContents formats are there.
I already have .docm files that have simple formatting macros embedded in them. The macros work. However I have 100+ different .docm files that use basically the same macro. Instead of changing the macros on all 100+ .docm files when I need to change a format, I would like to place the macro in a separate text file in a stable location on a network drive and have the macro code in each .docm file reference that text file.
I tried a Call Shell(AppName,1) statement where the AppName contains the path of the txt file, but the compiler won't work with a colon.
I researched creating a macro to change other macros embedded within each document, but was advised against it due to virus scanners.
It's not possible to run a macro from a text file, the way you imagine. (Cool idea, but a security risk, I think.)
Better would be to bring all the macros together in a single template (dotm), which you put in your STARTUP folder. When Word loads, it will load this template (with all its Ribbon customizations and macros) as an "add-in". (See also the Developer/Add-ins dialog box, which is where these can be managed.)
In this way, your code can be managed centrally - but you do have to explicitly open the template in order to make changes to the code. It can't be done just over the loaded add-in (that's only possible with Normal.dotm).
You can also have macros in this add-in template that you call from other macros. This can be done using the Applicaton.Run method.
I have an excel sheet with too many columns, so when I save it as a PDF the file its in too many pages and its not easy to read . I need to save the sheet as pdf but before I want to change its orientation to horizontal so I can read the pdf with no problem. Is the same you can do when you print but I want it when I save an excel file as pdf.
Is there any option I can choose?
I dont mind if someone gives me a code for a macro using my selection as an object.
Under the "Page Layout" tab, click the "Orientation" option and then select "Landscape."
Then create your PDF as usual.
You can save Excel files in PDF, even without using Excel. I use a program Universal Document Converter (http://www.print-driver.com/how-to/save-excel-as-pdf). This program allows you to quickly and easily create print-ready PDF-files on the basis of the original spreadsheets Excel.
Powerpoint file is actually a zip file that contains xml sub-files. These sub-files illustrate all the properties of objects of every slides (e.g., position, color, animation, etc.). You can convert the pptx file into zip file and unzip it you will see sub xml files.
Now, I want to create a Powerpoint Add-in application, allowing me to add more information to a specific object, and store dynamically it in itself XML file (or when saving file as). For example, my Add-in PowerPoint application contains a button named "Flippable". When I select a specific object of a slide, and select "Flippable", my application will find the xml file that contains the object information, and add a tag "Flippable = true".
Is it possible to do that dynamically when running application?
Thanks
Why go to all the effort of cracking and parsing the XML file, assuming that you even can while he presentation's open in PPT, especially since you're already doing this from an add-in?
You mentioned that the user has selected a shape. Why not just tag the shape:
With ActiveWindow.Selection.ShapeRange(1)
.Tags.Add "Flippable", "Yes"
End With
You'd want a bit more code around that to make sure that there IS a selection, and if you want to allow tagging multiple shapes at one time, you'd need to put in inside a For Each/Next loop.
Then assuming a reference to the current shape to be tested in oSh
If oSh.Tags("Flippable")="Yes" Then
' Do your stuff
End If
I have written VBA code that copies an entire workbook (worksheets and code) into another. This allows me to create a unique workbook containing only worksheets I need for a particular project. Everything works great except when I copy a workbook which has a worksheet with a picture. It imports OK but when I try to save the receiving file I get a message saying "Errors were detected while saving 'filename'. Microsoft Excel may be able to save the file by removing or repairing some features....". If I continue it says it can not repair the file. If I delete the picture it saves just fine. Any ideas on what is causing this and how to fix it? I tried png, jpeg, and tiff file types.
For me this error happened when I pasted in a graphic straight from ms-paint. I saved that graphic instead as .jpg and inserted it using Excel->Insert->Picture.