Results 1 to 19 of 19

Thread: Solved: Remember last saved toolbar position

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #12
    VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,168
    Location
    You are correct.

    The problem will also show up in the SaveSettingIni .

    change:
    WriteSettingIni (YOUR_TOOLBAR_NAME)
    to:
    WriteSettingIni (Application.CommandBars(YOUR_TOOLBAR_NAME))
    change:
    SaveSettingIni (YOUR_TOOLBAR_NAME)
    to:
    SaveSettingIni (Application.CommandBars(YOUR_TOOLBAR_NAME))
    BTW I have changed the subs to:

    Sub SaveSettingIni(iToolBar As CommandBar)
        Dim DirLoc As String
        DirLoc = "C:\Program Files\Microsoft Office\OFFICE11\ADDINS\"
        With iToolBar
        WriteIniValue DirLoc & "MyADDIN.ini", "Settings", "Position", _
        CStr(.Position)
        WriteIniValue DirLoc & "MyADDIN.ini", "Settings", "RowIndex", _
        CStr(.RowIndex)
        WriteIniValue DirLoc & "MyADDIN.ini", "Settings", "Left", CStr(.Left)
        WriteIniValue DirLoc & "MyADDIN.ini", "Settings", "Top", CStr(.Top)
        End With
    End Sub
    
    Sub ReadSettingIni(iToolBar As CommandBar)
        Dim DirLoc As String
        DirLoc = "C:\Program Files\Microsoft Office\OFFICE11\ADDINS\"
        With iToolBar
        .Position = Val(ReadIniValue(DirLoc & "MyADDIN.ini", "Settings", _
        "Position"))
        .RowIndex = Val(ReadIniValue(DirLoc & "MyADDIN.ini", "Settings", _
        "RowIndex"))
        .Left = Val(ReadIniValue(DirLoc & "MyADDIN.ini", "Settings", "Left"))
        .Top = Val(ReadIniValue(DirLoc & "MyADDIN.ini", "Settings", "Top"))
        End With
    End Sub

    it may make more sense now. So change WriteSettingIni to ReadSettingIni and you should be up and running!
    Last edited by Aussiebear; 04-28-2023 at 09:37 PM. Reason: Adjusted the code tags

Posting Permissions

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