Author Topic: On App Activate Event  (Read 6524 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
Re: On App Activate Event
« Reply #30 on: October 18, 2007, 11:26:29 AM »

OK, well, here is my last attempt
The code works well but it still did not resolve the problem
DAM cui files!  :pissed:

The below code will check for your Active Profile,
Your current menu (main cui) file
Then set the workspace you want to be current.

Thanks again Matt!

Mark

Code: [Select]
Sub WsCurrent()

Dim Username As Variant
Dim Preferences As AcadPreferences
Dim ActProfile As String
Dim CurrMenuPath As String
Dim CurrMenuFile As String


Set WshNetwork = CreateObject("WScript.Network")
Set Preferences = ThisDrawing.Application.Preferences

Username = WshNetwork.Username
ActProfile = Preferences.Profiles.ActiveProfile
CurrMenuPath = "C:\Documents and Settings\" & Username & "\Application Data\Autodesk\Autodesk Land Desktop 2006\R16.2\enu\Support\"
CurrMenuFile = Preferences.Files.MenuFile


If ActProfile = "Land Desktop" Then
  Select Case CurrMenuFile
   Case Is = CurrMenuPath & "land"
   ThisDrawing.SetVariable "wscurrent", "Land Destop Complete"
  End Select
End If
If ActProfile = "MapGeneral" Then
  Select Case CurrMenuFile
   Case Is = CurrMenuPath & "acmap"
   ThisDrawing.SetVariable "wscurrent", "Map Classic"
  End Select
End If

End Sub

Guest

  • Guest
Re: On App Activate Event
« Reply #31 on: October 19, 2007, 05:54:04 PM »
It's NOT gonna work because you STILL haven't spelled it correctly!!!

Quote
ThisDrawing.SetVariable "wscurrent", "Land Destop Complete"


 :wink: :-)

ML

  • Guest
Re: On App Activate Event
« Reply #32 on: October 19, 2007, 05:55:15 PM »

LOL

Good catch! :)

Mark

ML

  • Guest
Re: On App Activate Event
« Reply #33 on: October 19, 2007, 05:55:33 PM »

Have a great weekend man!

ML

  • Guest
Re: On App Activate Event
« Reply #34 on: October 31, 2007, 10:49:29 AM »

OK, I definetely got it now and it is doing exactly what the article said
On startup, set the workspace that you want current to be current.

This fixed my toolbar location problem; they are now being retained on each start of ACAD.
I think my earlier approach to the coding was the reason it was not working.

If anyone is interested; here is my approach and code:
Again, for me, it is working just fine.

Mark

On Startup, in The acad.dvb file
Code: [Select]
Sub Acadstartup()
Set AutoCAD = ThisDrawing.Application

RunMacro ("WsCurrent")  '<----- This is calling my WsCurrent Module

End Sub

WsCurrent Module:

Code: [Select]
Sub WsCurrent()

Dim Username As Variant
Dim Preferences As AcadPreferences
Dim ActProfile As String
Dim CurrMenuPath As String
Dim CurrMenuFile As String

Set WshNetwork = CreateObject("WScript.Network")
Set Preferences = ThisDrawing.Application.Preferences

Username = WshNetwork.Username
ActProfile = Preferences.Profiles.ActiveProfile
CurrMenuPath = "C:\Documents and Settings\" & Username & "\Application Data\Autodesk\Autodesk Land Desktop 2006\R16.2\enu\Support\"
CurrMenuFile = Preferences.Files.MenuFile


If ActProfile = "Land Desktop" Then
 CurrMenuFile = CurrMenuPath & "land"
 ThisDrawing.SetVariable "wscurrent", "Land Destop Complete"
End If
If ActProfile = "MapGeneral" Then
 CurrMenuFile = CurrMenuPath & "acmap"
 ThisDrawing.SetVariable "wscurrent", "Map Classic"
End If

End Sub