Results 1 to 2 of 2
  1. #1
    koetjeboe
    Guest

    Word VBA Commandbars

    Hi All,

    I've created a custom commandbar in Word. One of the buttons on it activates another commandbar. The state of the button is then msoButtonDown.

    When I have multiple documents open and I press the button, the commandbar is only visible in the current window, but the state of the button is msoButtonDown for all open windows.

    I tried to activate the commandbar in all open windows and that works fine. The only thing is that you see all these windows getting activated. Does anybody knows how to get rid of that?

    My code when the button is pressed:

    Sub Werkbalk_Indeling()
    Dim DocNaam As String

    If ThisDocument.Saved = True Then
    SavedAddin = True
    Else
    SavedAddin = False
    End If

    DocNaam = ActiveDocument.Name
    Application.ScreenUpdating = False

    If CommandBars("Burotica Indeling").Visible = True Then
    For Each Mydocument In Documents
    Mydocument.Activate
    Mydocument.CommandBars("Burotica Indeling").Visible = False
    Mydocument.CommandBars("Burotica Indeling").Enabled = False
    Next
    CommandBars("Burotica Huisstijl").Controls(13).State = msoButtonUp
    Else
    For Each Mydocument In Documents
    Mydocument.Activate
    Mydocument.CommandBars("Burotica Indeling").Enabled = True
    Mydocument.CommandBars("Burotica Indeling").Visible = True
    Next
    CommandBars("Burotica Huisstijl").Controls(13).State = msoButtonDown
    End If

    Documents(DocNaam).Activate

    If SavedAddin Then
    ThisDocument.Saved = True
    End If

    End Sub

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word VBA Commandbars

    Hah! You catch me right in the middle of the same exercise (and I'm about to post some of MY questions, so I can post them here and we'll have one thread).

    I' spent yesterday adding a drop-down-list to the Word97 File menu, and got it working, opened a document, and the drop-down disappeared. Dropped-down-dead.

    Closed the document, sparang back to life.

    I am still unsure what causes all this but it SEEMS to me that when the template that hosts the new menu item, or at least, the template i was using to create and process the item, is made GLOBAL by placing it in the Startup directory, everything stays alive and hums along quite happily.


    Again, I'm not sure WHY the behaviour, doubtless I'll find out. When that slaggard Kevin tells me he got my draft template to work, I'll post it here and you can ALL see what I'm doing. (It's the MRU list project)



    This morning I spent four hours trying to add controls to a new item in the menu bar. I can see all eight attempts when I view the item in the Locals Window of VBE, but they don't appear on the menu at all, at all!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •