PDA

Click to See Complete Forum and Search --> : [Resolved] Experience with Acrobat Add-In and Word CommandBar


pingel
Apr 17th, 2006, 01:28 PM
Does anybody have any experience with VBA scrips modifying the Menubar (using the CommandBar functions) and at the same time having the Acrobat 7.x PDFMaker COM Add-In loaded.

My menus get "screwed" up because of the Adobe COM Add-In, and I can't seem to get any help on the Adobe site.

I need to develop a stable solutions but at the same time allow for users to have the Adobe system loaded.

Thanks

:-)an

DKenny
Apr 17th, 2006, 01:32 PM
Welcome to the forums!

When you say 'My menus get "screwed" up', what exactly is happening?
Also, can you post the code you are using to build the menus.

Giving a detailed explaination of the issues and posting you code will always help you to get a quick response.

pingel
Apr 17th, 2006, 02:16 PM
By "screwed" up I mean that Either my menu in the main menu bar gets the content of one of the Adobe menus ("Adobe PDF" or "Adobe Comments") or the Adobe menus' gets the content of my menu or the Adobe menus become empty.

My code is very simple:

...
CustomizationContext = Application.ActiveDocument

Set MainMenuBar = Application.ActiveDocument.CommandBars.ActiveMenuBar
Set HelpMenu = MainMenuBar.Controls.Item("Help")
Loc = HelpMenu.Index
Set TestMenuBar = MainMenuBar.Controls.Add(Type:=msoControlPopup, Before:=Loc, Temporary:=True)
TestMenuBar.Caption = "Test"
Set newMenu = TestMenuBar.Controls.Add(Type:=msoControlButton, Temporary:=Temporary)
newMenu.Caption = "Testing function"
newMenu.OnAction = "TestFunction"
...

This places a pulldown menu - right before the help menu with the name Test and with one action on the menu called "Testing Function"

I also have some code to delete the menu before the document is saved:

...
CustomizationContext = Application.ActiveDocument
If IsEmpty(TestMenuBar) Then
Set MainMenuBar = Application.ActiveDocument.CommandBars.ActiveMenuBar
' For all found - delete them
For Each C In MainMenuBar.Controls
If C.Caption = "Test" Then Set TestMenuBar = C
Next C
End If
TestMenuBar.Delete
...


The special thing to specify here it that the code is placed in a Word Add-In Template, that acts on every document in the system when they are opened etc.
If you just run the code in a Document it seem to work fine

I can't find a specific pattern to how the Acrobat Add-In modifies my menu, but it is very annoying, and because it is a COM add-In and cannot be controlled (or even explained)
My post was primarily to see if anybody else had seen some weird activity when modifying the MenuBar with the Adobe Add-In active, and maybe had some suggestions.

Appreciate your help. Thanks

:-)an

pingel
Apr 28th, 2006, 10:23 AM
I finally resolved this issue with a lot of testing and retrying ....

Recap: I am developing a VBA Add-In for Word that will allow me to control the editing of new documents.

It all lies in CustomizationContext that guides where the changes to menus are activated.

First found out that by changing CustimizationContext to ActiveDocument before any changes to the menus the menus are pretty stable including the Adobe menus.

Second problem is that when I opened my template document it would screw up the menus on my already opened document. (I needed to open the template document to copy bookmarks from that document to my new document - you cannot copy context from a loaded Add-In - the document has to be openend as an active document). It seemed like the Acrobat Add-In (or effects thereoff) would run on my already opened document and it would mess up the menus.

The solution is to change the CustomizationContext to the document I am openening before I open it. I can do that because the document is already loaded as an Add-In and I can refer to ThisDocument in the macros.
I then change the CustomizationContext back to ActiveDocument after the template is closed again. Now there are no changes to the menu of the Document I am working on.

I have been trying to get some info from the Adobe Forums about the Acrobar COM Add-In, but with no luck. It would be nice to know exactly what it is doing and then taylor the solution to that.

:-)an