Powerpoint 2007 - Inserting dynamic data - vba

so I've found that Powerpoint 2007 has no bookmark functionality. So I can't just insert dynamic data into a presentation. Also, there are no autostart event handler, but I found a way of doing it by editing the XML data. This now works, I've got a custom event handler that is run as expected.
Now, I tried to solve the no bookmark functionality by adding a label insted. Since a label has a name I can assign the Caption property a value. And that value can be dynamic data.
And this actually works, yay! BUT, this presentation has a custom font and font embedding is crucial. And now I've found that PowerPoint 2007 doesn't look to support font embedding on labels. And probably not buttons and textboxes as well. That is, the typical visual studio controls.
Are there any other ways of fixing this? A normal text placeholder doesn't have an ID.
But can I target them anyway? It's just some text in the footer of a slide design that I'm trying to put dynamic data.

Ok, so I found out how to target textboxes in PowerPoint 2007.
ActivePresentation.SlideMaster.CustomLayouts.Item(11).Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1, Length:=25).Select
ActiveWindow.Selection.TextRange.Text = "New text that should be inserted"
The problem now is how to run this automatically. New thread for that.

Related

Word 2010 ActiveX control forms - formatting issues

Hopefully a quick one
I am creating a form in Word with a Save macro that uses an ActiveX Label as a button. The label works fine as a button but I am having 2 issues:
when using the document in normal mode, the coding text in curly brackets for the label is still visible - see image
How do I get rid of this?
When printing the form, the button pushes the header text down a line:
You can see in the first picture that there is no gap here.
Thanks for your help.
(1) Press Alt+F9 to toggle off display of field codes (and make sure you're not in Design Mode).
(2) is impossible to be sure without having the document in front of me but...
Printing problems are notorious with ActiveX controls, which were designed for use with UserForms, not for the document surface. Your best bet for stability would be to use a one-row, two-column table with the button on the left and the address on the right.
Or use a MacroButton field code instead of an ActiveX control.

How put custom icon to Visio Document for custom ribbon

I am trying to put custom icon to Visio Document for custom ribbon. When I using Excel I can use utility “Custom UI Editor for Microsoft Office”. For example, I can write next xml in utility and insert some picture:
Custom UI Editor
In Excel all working excellent.
But when I trying use this way in Visio, I don’t see picture on ribbon when I opening Visio-document.
After that I opening “Custom UI Editor for Microsoft Office” for Visio-document I also don’t see inserted picture that I inserted before.
Custom UI Editor after opening Visio-document
Can anyone help me out with my problem? Thank you.
This is a known issue in Visio. Custom icons in .vsdx file simply do not work.
If you are really determined to have custom pictures, you should do it otherwise.
Like via VBA macro, by writing a callback, i.e. instead of image specifying getImage pointing to some callback function to get the custom image. Or even by creating a full-blown extension.
Note - Microsoft-defined (idMso) images work fine.

Word Macro to add predefined content at the end of document on click of button

I have an document in word, which has some fields to be filled, and an button to which I want to assign a macro. When that button is clicked, that same form with empty fields needs to be appended to the end of document, including the button (which can be clicked again and do the same thing).
Here is the document I have:
https://drive.google.com/file/d/0B_2kyqxMx5x4UkxfOHJhOGVPdnc/view?usp=sharing
The main problem with what you want to do is dynamically linking the button to the macro code to be executed. The most obvious type of button to use is the legacy ActiveX control in the Ribbon's Developer tab. But that requires its own procedure entry in the document's ThisDocument class module. While it's possible to add code to modules "on the fly" this involves disabling a security option.
A more straignt forward approach is to use the MacroButton field. This creates a clickable text within the document. It can display text or a graphic (so that it looks like a button) and is assigned the name of any public Sub that takes no parameters:
{ MACROBUTTON NameOfMacro Click here }
Ctrl+F9 to insert the field code brackets; Alt+F9 to toggle between field code and field result.
Graphics in Word 2010 and later:* The was a change to the graphics engine in Word 2010 which affects the behavior of graphics objects in the MacroButton field. Clicking the object triggers the Ribbon utility for working with graphics - the field code no longer "hides" the graphic. There are a number of ways you can work around this:
Use an IncludePicture field (which works with the old graphics format) to bring in an outside picture file. Once the linked picture is in the field it can be converted to a static picture by selecting the IncludePicture field and pressing Ctrl+Shift+F9. Word respects the old graphic format and the picture is click-able.
{ MacroButton NameOfMacro {IncludePicture "C:\\Path\\picture.jpg" } }
Use the old *.doc file format. Note that this will restrict some of the things that can be done with the document, but it will force use of the old graphics engine.
Instead of a MacroButton field, use the WindowBeforeDoubleClick event or WindowSelectionChange event to run the code.
*With the exception of unlinking the IncludePicture field (which I discovered myself), this information came from this discussion on the Microsoft Answers site
If you want to run the macro with a single rather than a double-click (the default) you need to run the following line of code. This applies to the entire Word application and needs to be run everytime Word restarts. You could put it in an AutoNew macro in the template / AutoOpen macro in the document:
Application.Options.ButtonFieldClicks = 1
The simplest way to store the entire content you want to insert repeatedly is as a Building Block (formerly known as AutoText).
BuildingBlocks are stored in templates. If your document is being created from a template, that would be the logical place. Another possibility would be a special template you use for this purpose. Normal.dotm can also be used but keep in mind this does sometimes get removed.
(Note: if you're using a template for the document that would also be the best place to store the macro attached to the macro button.)
Once this is set up, all your code needs to do is insert the BuidlingBlock at the end of the document.

Editing Word 2003 template with custom toolbar in Word 2007

I only have Word 2007 and a Word 2003 template (.dot file).
When I open it, I can see it has macro's in it, stored in modules. I can also see that the template adds buttons to the add-ins tab in the ribbon.
How can I modify these buttons? Like the text or which macro each button triggers?
As a test I deleted all macros in the template, saved it, restared it, and it still gave me custom buttons in the Add-in tab. Of course if I press those buttons, it gives me error that the macro is not there. Which is fune. Then, if I view the template's code (Alt-F11), there is really no code at all. Also no Add-in is loaded (as seen in the Word options > Add ins window). So how does the Word 2003 template know which buttons to load? Where is the custom toolbar info stored in the Word 2003 template?
i am not sure i fully understood your question. Yet, here are a few elements.
Modify the buttons generated by a macro
You have to change the vba code. See :
this link for Word 2003 : http://www.ozgrid.com/VBA/custom-menus.htm
this link for Word 2007+ : http://www.rondebruin.nl/ribbon.htm
Buttons already loaded
If your custom buttons still appear after you deleted the code :
i'd think that you missed some part of the code to delete, can you re-check ? in every module of the doc
are you sure you didn't save a doc instead of saving the template ?
If these tips doesn't answer your question, please give us some more info on your problem or if possible, give us the template you are using.
Regards,
Max

Read values from the Office 2007 ribbon using VBA

Using VBA, can I find out the value of a text (combobox) control on the Word 2007 ribbon?
Say I'd want to read the currently selected font name in the "Home" tab.
I've seen an example using the IAccessible interface to do some interaction with the Ribbon (namely enumerating it), but it seems reading a control value is not possible. Is there another way to do it, or is VBA locked out completely?
I don't think you can get at the ribbon to read the built in properties.
For you specific example of Font name you can use the following.
Msgbox Application.Commandbars.Findcontrol(ID:=1728).Text
You maybe able to adpat the approach for other information.