I've been working on a Word macro that includes a step allowing the user to select and insert a Visio file into the active Word document. Since many of the source Visio files are multipaged, and the specific Visio drawing to place in Word could be on any page of the Visio document, I need a way to allow the user to select the page they want to place.
Currently, my VBA code uses Appplication.FileDialog(msoFileDialogFilePicker) to set a variable for the Visio drawing's filepath (myVisioPath), then creates a variable for the Visio file and inserts it it into the Word doc as follows:
Dim myViz As InlineShape
Set myViz = ActiveDocument.InlineShapes.AddOLEObject(ClassType:="Visio.Drawing.15", FileName:=myVisioPath, LinkToFile:=False, DisplayAsIcon:=False, Range:=Selection.Range)
myViz.Select `Selects the Visio for subsequent actions`
The current working version of the macro selects whatever is on page 1 of the selected Visio file. I need a way to allow the user to select page 2, or page 3, or whatever page the target drawing is on in the Visio file. Currently, I'm thinking of creating a userform to allow choosing a page number, but I'm open to suggestions.
The post by Mathieu Guindon led me to the answer (would have voted it as the answer but that doesn't appear to be an option). Anyway, the code posted at Choose active page in Visio provided the basis of my solution. Set a variable for the Visio.Application object and refer to it to get both the page count of the user-selected Visio file (for error trapping if the user selects a page number that isn't available in the file) and to copy the user-selected page.
Related
I am currently working on creating a template for a business presentation.
After the current client's name is written in the starting slide I want to be able to take it and place it on X amount of slides later created via a template, so that manual entry is almost completely reduced (this is a prerequest for the task).
Is it possible to create a macro so that it either edits the template slides after the needed information is written on the 1st slide or that it controls all the user created slides and labels afterwards?
What you're after is possible so long as the user can either install an add-in that you've written to do the job or open a file that you've saved as a PPTM rather than PPTX (ie, one with macros/vba included).
I've just input a form button on my Excel sheet that the users can press to get more information on how parts of my code run. I'm planning on writing a big Word document that explains the different parts of the code in different sections. I'm looking to have a button that the user can click on in Excel for each part of the code, and that will direct them to the specific section within the Word document that I'd like to link.
So I can open a specific Word document with VBA no problems, but I'm unsure how/if I can jump to sections within the Word document.
If you use Hyperlinks instead of buttons, you can jump directly to bookmarks in your Word document, no VBA needed.
E.g. create a bookmark "Section5" in your Word document.
Then create a hyperlink in an Excel cell, with this target:
file://your_path\your_document.docx#Section5
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 a word doc with some ActiveX buttons on it. When one of these buttons is pressed, a UserForm pops up with a corresponding PDF displayed, like so:
This is exactly the behavior I want. However, the problem is that for this to work, the user of the word doc needs to have each of the PDFs saved on their machine as well. Here's the code for one of the buttons:
Private Sub AC1Button_Click()
DisplayForm.AcroPDF1.LoadFile ("C:\Users\arose\Desktop\Security Control Doc\Sub PDFs\AC1.pdf")
DisplayForm.Show
End Sub
As you can see, the path is hardcoded in. I need to be able to distribute this word doc without needing to distribute a bunch of PDFs along with it, so is there any way to embed PDFs in a word document in such a way that they're accessible by VBA?
I've discovered here that it's reasonably easy to embed a PDF in any office doc. And I've tried that:
But I can't figure out how to access that PDF object in my VBA code, in order to display it on the UserForm.
Any insight is appreciated, thanks!
Embed the files (and display as icon to stop them taking over your document)
To activate the first OLE object in your document,
ThisDocument.InlineShapes(1).OLEFormat.Activate
is the command.
I'm building a VSTO add-in for Powerpoint 2010 and the options the add-in sets apply to the currently open file instead of a per-user config. Can I save these options in the current file (I mean, add custom XML to the .PPTX file)? If so, how?
Thanks for your help.
For very simple data, custom properties are ok (so long as you're aware that anyone who opens the file will be able to see, edit and delete them). And note that because PPT shares a common, too-small, allocation of data between links and document properties, adding too many of one can wipe out the other.
I'd use tags instead. Every shape, slide and presentation object can have a tags collection, containing one or more Name / Value pairs of strings.
These are invisible to the user and will not interfere with the hyperlinks in the presentation.
' To add a tag
With ActivePresentation
.Tags.Add "MyTagName", "MyTagValue"
End With
' To use a tag
If ActivePresentation.Tags("MyTagName") = "MyTagValue" Then
' Do something or other
End If
If your Options are not too complex, I would go for Document Custom Properties. The following question illustrates how to use Custom Properties with Excel, they are supported in PowerPoint as well so this should provide a good starting point!