I'm not new to VBA but I am new to using VBA with word. When I go to the VBA my project explorer shows a Normal and a Project folder. I have several bookmarks in my document and I put macrobuttons in the document to collapse and expand the paragrpahs which are the bookmarks. For example:
Sub WriteRangeNamesToSheet()
ActiveDocument.Bookmarks("WriteRangeNamesToSheet").Range.Font.Hidden = _
Not ActiveDocument.Bookmarks("WriteRangeNamesToSheet").Range.Font.Hidden
End Sub
This is the documentation for some code I had written for an excel application. I have this code in the "Project/ThisDocument" folder. There are several of these since I couldn't figure out how to use a common routine and pass a parameter. Some of them work, some don't. My macro button looks like:
{MACROBUTTON WriteNamesToSheet >}
When I double click the > some work, others don't. I wrote a little routine and called it from the immediate window to expand all of the paragraphs.
Sub OpenAll()
Dim bod As Object
For Each bod In ActiveDocument.Bookmarks
bod.Range.Font.Hidden = False
Next
End Sub
This worked as written. I added {MACROBUTTON OpenAll [Click to Expand]} to my document and hit Alt-F9. When I double click or just single click on [Click to Expand] nothing happens. I set a break point and the sub is never called. Does this sub go into the Normal/ThisDocument or the Project/ThisDocument?
What would make the macrobutton NOT call the sub? Is Macrobutton case sensitive. I have not found any decent documentation. I read the documentation on passing arguments using Private and AddIn. But neither example worked. The Addin example just showed {MACROBUTTON MyMacro [Click]{AddIn}}. I don't know where the added argument is.
I would like this seemingly simple thing to work. A little experienced insight would be appreciated.
Thanks,
Scott