PDA

View Full Version : Excel will not launch sometimes



sgroff
2007-03-22, 11:56 AM
Okay, i wrote this code to set the File tab paths in Options. In order to get the Tool Palette groups to show up, I have to copy a file to the Hard drive after closing ADT ( or LDT or MAP or Vanilla CAD)
I wrote the excel sub to open file, I know it's not the best way to open the xls file. but so far, its the only way i've been successful. When the XLS file opens, a macro autoruns and ask me which piece of software i am replacing the file for.
Any way, the Excel file opens on our traininig machines, and on my machine. I've tried two workstations and excel doesnt open the first time around. I can run the sub from the VBA interface and everything happens as planed.

What am i missing? Any thoughts are greatly appreciated.




Sub ADT2007Setup()

Dim sCurUser As String
Dim acadPref As AcadPreferences

sCurUser = Environ("username")

Set acadPref = ThisDrawing.Application.Preferences
acadPref.Files.SupportPath = "C:\Documents and Settings\" & sCurUser & "\Application Data\Autodesk\ADT 2007\enu\support;c:\Program FIles\Autodesk Architectural Desktop 2007\support;c:\Program FIles\Autodesk Architectural Desktop 2007\fonts;c:\Program FIles\Autodesk Architectural Desktop 2007\support;c:\Program FIles\Autodesk Architectural Desktop 2007\help;c:\Program FIles\Autodesk Architectural Desktop 2007\express;C:\Documents and Settings\" & sCurUser & "\Application Data\Autodesk\ADT 2007\enu\Support\pats;c:\Program FIles\Autodesk Architectural Desktop 2007\support\color;C:Program Files\Common Files\Autodesk Shared;C:\windows\Fonts"
acadPref.Files.PrinterConfigPath = "G:\CADD Standards\plotters"
acadPref.Files.PrinterStyleSheetPath = "G:\CADD Standards\Plot Styles\Arch"
acadPref.Files.AutoSavePath = "c:\Temp"
acadPref.Files.TemplateDwgPath = "G:\CADD Standards\Templates\Architectural\"
acadPref.Files.QNewTemplateFile = "G:\CADD Standards\Templates\Architectural\LSC_ArchADT07.dwt"
acadPref.Files.ToolPalettePath = "C:\Documents and Settings\" & sCurUser & "\Application Data\Autodesk\ADT 2007\enu\Support\WorkspaceCatalog (Imperial);G:\CADD Standards\ADT2007\LscToolPalettes\LSC Architectural Department\Categories\Categories;G:\CADD Standards\ADT2007\LscToolPalettes\LSC Architectural Department\Categories"
acadPref.Files.TempFilePath = "c:\Temp"
acadPref.Files.TempXrefPath = "c:\Temp"

'opens an Excel file with a macro that replaces a support file on the users hard drive. Autocad will close after Excel opens

ThisDrawing.Excel


End Sub

Sub Excel()

SendCommand "start" & vbCr
SendCommand "G:CopyPrefFiles.xls" & vbCr

MsgBox "All paths have been updated. Excel should be open & this application will close after pressing OK", _
vbInformation, "Ready To Copy Files"

SendCommand "quit" & vbCr

End Sub

Ed Jobe
2007-03-22, 02:13 PM
Try using Shell.

sgroff
2007-03-22, 02:31 PM
i tried shell first. But then it doesnt close the DOS window after acad closes. & i'm anal about that :)

I did manage to fix this by using an example from the help file.

thanks for the suggestion though