Author Topic: Setting a Cui to Main with VBA  (Read 1240 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
Setting a Cui to Main with VBA
« on: April 25, 2007, 02:17:03 PM »

I can across The Menufile object under Preferences and realized that is what controls what cui file is the main (customizable) cui

So, I began to write a few macros just to switch beween my working cui and my custom cui.

The first macro is working like a charm but with the second one, it is setting the path to the proper cui and it is saying that my my current workspace that I told it to be is current. However, the toolbars menus etc are not appearing???????????

If I go to the cui editor and right click on the workspace and choose set current, then all is fine.

If the first macro works fine, then the second one "should" work fine as well. Any help is appreciated.

Mark

First macro that works well:

Code: [Select]
Sub Custom()

Dim Preferences As AcadPreferences
Dim MainCuiFile As String


Set Preferences = ThisDrawing.Application.Preferences

'Set a reference to The Main Cui File Path and File
MainCuiFile = "C:\Documents and Settings\my username\Application Data\Autodesk\Autodesk Land Desktop 2006\R16.2\enu\Support\custom.cui"

'The MenuFile = Custom.cui
Preferences.Files.MenuFile = MainCuiFile

'Set The Current Workspace to Custom1
ThisDrawing.SendCommand "wscurrent" & vbCr & "Custom1" & vbCr

MsgBox "The current main cui file is " & MainCuiFile, vbInformation, "Main Cui"

End Sub

Second macro, not working well????

Code: [Select]
Sub Land()

Dim Preferences As AcadPreferences
Dim MainCuiFile As String


Set Preferences = ThisDrawing.Application.Preferences


'Set a reference to The Main Cui File Path and File
MainCuiFile = "C:\Documents and Settings\my username\Application Data\Autodesk\Autodesk Land Desktop 2006\R16.2\enu\Support\land.cui"

'The MenuFile = land.cui
Preferences.Files.MenuFile = MainCuiFile


ThisDrawing.SendCommand "wscurrent" & vbCr & "Survey" & vbCr

'Set The Current Workspace to Land Desktop Complete
ThisDrawing.SendCommand "wscurrent" & vbCr & "Survey" & vbCr

MsgBox "The current main cui file is " & MainCuiFile, vbInformation, "Main Cui"

End Sub