Combobox Change, AfterUpdate, and BeforeUpdate Events in Word VBA - vba

What is the difference between Change, AfterUpdate, and BeforeUpdate events for Combobox in Word VBA?
I'm having difficulties in finding documentation for control events in Word VBA (I only found documentation for Access VBA and VB.NET, I don't know if they behave in the same way)

This information is in the Language Reference for MS Forms ("User forms") for Office VBA, rather than in the Help for individual Office applications, which is why you may have had difficulty finding it. For example:
https://msdn.microsoft.com/EN-US/library/office/gg264307.aspx
https://msdn.microsoft.com/EN-US/library/office/gg264215.aspx
https://msdn.microsoft.com/EN-US/library/office/gg264715.aspx

Related

Office VBA- detect PowerPoint slide change

I'm creating an application where I'd like to be able to show users an ongoing PowerPoint presentation over the web, where the slide changes as the presenter does so in real time. I've looked at the Office VBA documentation and I didn't see any event for this. The closest I've come are these events, but I don't see anyway of doing what I need to using these.
How can I detect slide changes in Microsoft Powerpoint using Visual Basic?
It seems that this is what you are looking for: Application.SlideShowNextSlide Event
This is VBA Powerpoint object model though, but you should be able to find your way around...

How to put a button into Quick Access Toolbar in MS Word 2010 with a macro (VBA)?

I import bsa file as module. And macro run properly. I need to set up these macros buttons in to Quick Access Toolbar (QAT). I do it manually from standart way as well. But i want to make this automatically with macro (VBA). How these macros assigned to the buttons and buttons set up on the QAT by VBA inside macro?
I searched a lot, and the only way I was able to find was using Office Fluent User Interface.
See this article that walks you through doing it. The example is Excel's QAT, but since all Office Products share the same Type Library, you should be able to adapt it for MS Word 2010.

Outlook 2007 - VBA macro in NormalEmail.dotm

I have a Word 2007 template that I use as Normal.dotm, which has corporate theme, styles, etc., plus a tiny bit of macro code that overrides the default behaviour of the bullet & number buttons on the ribbon.
I'd now like to use this same template when creating emails in Outlook 2007. I've tried just copying my Normal.dotm to NormalEmail.dotm, and to an extent this works, but although my macro is correctly invoked when I press the bullet/number buttons in the email editor, it gives an error:
Run time error 429: ActiveX component can't create object
On further investigation, it seems that anything I do within my macro that references an object in the normal Word object model (Application, Selection, etc.) causes this error. So, even if my macro consists of the following, it still fails:
MsgBox TypeName(Application)
I have an inkling that this is because I'm running in the context of Outlook, not Word, and so perhaps there is no (Word) application, or any of the objects associated with it. I know that the email editor in Outlook is Word-but-not-as-we-know-it-Jim.
Having said that, I did discover that ThisDocument does return a valid Document object; unfortunately, it corresponds to the template itself, not the email being edited.
By trial and error, I've discovered that I can get at the Document corresponding to the email by the following circuitous route (this displays the text in the email):
MsgBox ThisDocument.MailEnvelope.Item.Application.ActiveInspector.WordEditor.Content.Text
However, this code also seems to cause Outlook to crash - not at the time, but later, when you close Outlook.
At this point, I'm just about ready to admit defeat. No doubt the "correct" way to create macros in Outlook is to create them in Outlook itself, but from my limited experience, that's just horrible. (You can create macros in VBA, but you can't deploy them; or, you can create them in VSTO, but then you need an installer rather than simply deploying a template).
So. Any ideas out there that would let me do all that I hoped to do?
Override the behaviour of the bullet/number buttons on the ribbon in the email editor.
Deploy the macros in the NormalEmail.dotm file, rather than having to "install" them.
Not crash Outlook.
Have you tried adding the reference in the VBA editor to the Microsoft Outlook Object Library?
In Outlook 2007 you might also have to add VBA references to "Microsoft Word 12.0 Object Library" and maybe "Microsoft Forms 2.0 Object Library". Different versions may apply for other version years.
In addition, in the macro/code you have to set the objects to get/use the correct methods and properties.
I'm not an OO programmer and usually copy code from elsewhere and modify for my need so I can't help much more than what I said above. (And one of my macros is also giving me the same 429 error you get.)

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.

Recording VBA code in Power Point 2007?

In Office 2003 if I recall correctly you had a "record macro" option.
In PowerPoint 2007, under View->Macros, you get a macro box. None of the options are "record". If you put in a name, you can select "create", but that takes you to the VB editor. If you edit the slide manually, it does not generate the VBA code.
You do not have the option of defining VBA code by a sequence of keystrokes/mouseclicks/whatever.
It seems you are out of luck What happened to the macro recorder?
I have since read:
Contrary to what Microsoft says, use
the legacy keyboard commands Alt+T, M,
R to start the macro recorder in
Powerpoint 2007, and use the same
keyboard combination to stop
recording.
The macro recorder works using this shortcut, but you should note that it won't record for features that were added after Powerpoint 2003 (and this includes anything to do with the new charting engine that was introduced in PPT 2007).
This isn't about arrogance, it's simply that 2007 was a BIG rewrite for all of the Office applications. To ensure that the product went out on time, some features had to be de-scoped and the macro recorder was one of them, since Powerpoint automation is used by a relatively small user group when compared with Excel or Word automation.
Powerpoint add-ins are common, but they're built by developers and although it's handy we can live without the macro recorder. Visual Studio isn't necessary for building Office Add-Ins, although it does have advantages. What you really need is someone competent in building Office solutions.
Both answers are correct the macro recorder can be activated but it is pretty much useless since it records little to nothing. It seems that the ppt programmers at MS really take issue with customers being able to customize powerpoint. Executing repetitive tasks or just formatting an object the way you want it (and not being stuck with the pre-cooked options that MS in its infinite wisdom or shall I say bloody arrogance believes is all you need) has become almost impossible. The only way out is to program the ribbon or create an add-in which has to be done in Visual Studio (VBA will not cut it).
The Keystroke activated record doesen't work it creates an empty macro with very few(usually none!) of the actual actions that you performed.