Results 1 to 20 of 117

Thread: Challenge!! Can you solve this problem?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    OF COURSE! THAT'S IT...(reading my last 2 posts)...If we make the procedure an Open event, any changes to the code can't be run until the document is saved and re-opened.

    Copy and paste the following code into "ThisDocument", save it, exit and open...

    Option Explicit
    
    Private Sub Document_Open()
        Dim intBeforeIndex As Integer
        Dim cmdbar As CommandBar
        Dim cmdbutton As CommandBarButton
        Const strToolbar As String = "Double Vision HK VBA"
        On Error Resume Next
        CommandBars(strToolbar).Delete
        Set cmdbar = CommandBars.Add(Name:=strToolbar, Position:=msoBarTop, Temporary:=False, MenuBar:=False)
        cmdbar.Visible = True
        Set cmdbar = CommandBars(strToolbar)
        intBeforeIndex = 1
        Set cmdbutton = cmdbar.Controls.Add(Type:=msoControlButton, Temporary:=False, Before:=intBeforeIndex)
        With cmdbutton
            .Style = msoButtonCaption
            .OnAction = "modReplaceStringNames.ReplaceStringNames"
            .Caption = "String Names"
        End With
    End Sub
    Hopefully we can mark this solvered now
    Last edited by Aussiebear; 05-07-2025 at 03:54 PM.

Posting Permissions

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