Message 1 of 4
Menus and Profiles

Not applicable
05-10-2000
09:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to write a Visual Basic program to install a menu into all (or
user selected) profiles that exist in Autocad 2000. The menu is an external
*.mnu file that I wish to load into the individual profiles. If I run the
code below and manually switch between profiles, running the macro to
install the menu each time, it works fine. If I try to automate it and have
Visual Basic set the current profile, install the menu, and then move to the
next profile, it doesn't work properly. When running it on multiple
profiles, the only profile that holds the menu is the last one in the
profile list. The remainder of the profiles will not have the menu
installed. The wierd part is that I can 'SEE' it working and it DOES add the
menus to each profile, it's just that when it finishes, only the last
profile still retains the menu. The portion of the program that adds to the
support path works fine and holds in all profiles. I hope I explained all
this well enough, at any rate, here is the code I am using. The menu I am
tryin gto load us called menu1.mnu......
Private Sub cmd_Done_Click()
Dim iCNT As Integer
Dim bSelected As Boolean
Dim sCurProf As String
frm_Install.Hide
sCurProf = ThisDrawing.Application.Preferences.Profiles.ActiveProfile
For iCNT = 0 To lst_Profs.ListCount - 1
bSelected = lst_Profs.Selected(iCNT)
If bSelected Then
Install_ALPro (lst_Profs.List(iCNT))
End If
Next iCNT
ThisDrawing.Application.Preferences.Profiles.ActiveProfile = sCurProf
Unload Me
End Sub
Private Sub Install_ALPro(ByVal sName)
ThisDrawing.Application.Preferences.Profiles.ActiveProfile = sName
Dim sPath As String
Dim iCount As Integer
Dim sCurSupp As String
Dim sNewMenu As AcadMenuGroup
sPath = "C:\Program Files\Menu1"
For iCount = 0 To MenuGroups.Count - 1
If UCase(MenuGroups.Item(iCount).Name) = "Menu1" Then Exit Sub
Next iCount
Set sNewMenu = MenuGroups.Load(sPath & "\Menu1")
sNewMenu.Menus.Item("&Menu1").InsertInMenuBar
(AcadApplication.Application.MenuBar.Count + 1)
sCurSupp = AcadApplication.Preferences.Files.SupportPath
If Not UCase(sCurSupp) Like "*Menu1*" Then
AcadApplication.Preferences.Files.SupportPath = sCurSupp & ";" & sPath
End If
End Sub
user selected) profiles that exist in Autocad 2000. The menu is an external
*.mnu file that I wish to load into the individual profiles. If I run the
code below and manually switch between profiles, running the macro to
install the menu each time, it works fine. If I try to automate it and have
Visual Basic set the current profile, install the menu, and then move to the
next profile, it doesn't work properly. When running it on multiple
profiles, the only profile that holds the menu is the last one in the
profile list. The remainder of the profiles will not have the menu
installed. The wierd part is that I can 'SEE' it working and it DOES add the
menus to each profile, it's just that when it finishes, only the last
profile still retains the menu. The portion of the program that adds to the
support path works fine and holds in all profiles. I hope I explained all
this well enough, at any rate, here is the code I am using. The menu I am
tryin gto load us called menu1.mnu......
Private Sub cmd_Done_Click()
Dim iCNT As Integer
Dim bSelected As Boolean
Dim sCurProf As String
frm_Install.Hide
sCurProf = ThisDrawing.Application.Preferences.Profiles.ActiveProfile
For iCNT = 0 To lst_Profs.ListCount - 1
bSelected = lst_Profs.Selected(iCNT)
If bSelected Then
Install_ALPro (lst_Profs.List(iCNT))
End If
Next iCNT
ThisDrawing.Application.Preferences.Profiles.ActiveProfile = sCurProf
Unload Me
End Sub
Private Sub Install_ALPro(ByVal sName)
ThisDrawing.Application.Preferences.Profiles.ActiveProfile = sName
Dim sPath As String
Dim iCount As Integer
Dim sCurSupp As String
Dim sNewMenu As AcadMenuGroup
sPath = "C:\Program Files\Menu1"
For iCount = 0 To MenuGroups.Count - 1
If UCase(MenuGroups.Item(iCount).Name) = "Menu1" Then Exit Sub
Next iCount
Set sNewMenu = MenuGroups.Load(sPath & "\Menu1")
sNewMenu.Menus.Item("&Menu1").InsertInMenuBar
(AcadApplication.Application.MenuBar.Count + 1)
sCurSupp = AcadApplication.Preferences.Files.SupportPath
If Not UCase(sCurSupp) Like "*Menu1*" Then
AcadApplication.Preferences.Files.SupportPath = sCurSupp & ";" & sPath
End If
End Sub