TheSwamp

Code Red => VB(A) => Topic started by: Hangman on January 17, 2011, 07:23:36 PM

Title: VBScript: How to determine which version of CAD ...
Post by: Hangman on January 17, 2011, 07:23:36 PM
Afternoon everyone,
I am writing a script to activate the currently running AutoCAD program on any given machine and then run a LiSP.
I am stuck on how to determine which version is currently running in order to make it active.
If I'm trying to do this:
Code: [Select]
Set WSO = WScript.CreateObject("WScript.Shell")
 ...
Function ActivateACAD()
  WSO.AppActivate "AutoCAD Map 3D 2011"   [color=green]' What if the user is running "AutoCAD Map 3D 2010"[/color]
 ...

Would I just use an IF statement?

Code: [Select]
IF NOT WSO.AppActivate "AutoCAD Map 3D 2010" Then
  WSO.AppActivate "AutoCAD Map 3D 2011"
End If

Thank you for the help.
Title: Re: VBScript: How to determine which version of CAD ...
Post by: David Hall on January 18, 2011, 07:59:48 AM
You could read the registry for the version number, maybe?
Title: Re: VBScript: How to determine which version of CAD ...
Post by: David Hall on January 18, 2011, 08:00:16 AM
Or maybe do a find file and read the returned path
Title: Re: VBScript: How to determine which version of CAD ...
Post by: fixo on January 24, 2011, 03:21:51 AM
Try the similar way

Code: [Select]
'demo.vbs
Dim WSHShell
Dim AcApp
Set WSHShell   = WScript.CreateObject("WScript.Shell")
Dim appname
appname="AutoCAD.Application"
Set AcApp = WScript.CreateObject(appname)
AcApp.Visible=True
WSHShell.AppActiVate AcApp.Caption

~'J'~