It seems that the code below works only if there is no space in the profile name itself, is there a way to overcome that? Thanks Private Sub US_Click() Dim Test Dim n3 As String n3 = "C:\PROGRA~1\AUTOCA~1\acad.exe /p" Test = "C:\DOCUME~1\ALLUSE~1\APPLIC~1\Autodesk\AUTOCA~1\Profiles\Test User NA.arg" Shell n3 & (Test), 3 End Sub
The Shell command expects a single string as an argument. The delimiter for a string is the double quote. Its also what you use to delimit long filenames. So you need a delimited string inside a string. There are two methods in vb, use a single quote or and escape char with double quote., e.g. "main string 'sub string'" "main string \"sub string\"" -- ---- Ed ---- profile name itself, is there a way to overcome that?
The way you had it, it was missing a space between the "/p" switch and the argument. Dim n3 As String n3 = "C:\PROGRA~1\AUTOCA~1\acad.exe /p " & _ "'C:\DOCUME~1\ALLUSE~1\APPLIC~1\Autodesk\AUTOCA~1\Profiles\Test User NA.arg'" Shell n3, 3
Watch for word-wrap. n3 = "C:\PROGRA~1\AUTOCA~1\acad.exe /p " & _ "'C:\DOCUME~1\ALLUSE~1\APPLIC~1\" & _ "Autodesk\AUTOCA~1\Profiles\Test User NA.arg'" -- ---- Ed ---- The way you had it, it was missing a space between the "/p" switch and the argument. Dim n3 As String n3 = "C:\PROGRA~1\AUTOCA~1\acad.exe /p " & _ "'C:\DOCUME~1\ALLUSE~1\APPLIC~1\Autodesk\AUTOCA~1\Profiles\Test User NA.arg'" Shell n3, 3
You should start n instance of AutoCAD through code, not use a shell command. From there, I don't think you'll have any issues with the profile string.
3DMax, Here is some untested code. Public Sub get_autocad() dim objAcad as AcadApplication set objAcad = GetObject(, "AutoCAD.Application") objAcad.Preferences.Profiles.ActiveProfile = strProfileName End Sub Note: I don't see an Add method for the Profiles collection. That means that if strProfileName does not exist, you will get an error. I believe that the default profile is always present. Correct me if I am wrong guys. I suppose you could to copy the default and rename/set settings on the copy in this case. Regards, Ken Hutson San Antonio, TX