Message 1 of 6
Running .scr scripts in VBA through Access 97
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've got the following below code in a command button event! Basically what I'm trying to do is run a .scr script through an opened instance object of AutoCAD. I'm firing all this through an Access97 form and it seems to work fine up until the point I do a objDwg.SendCommand "script" & vbCr & txtNameFile & vbCr. Now no error message is showing at all in Access if I go ahead and remove the On Error GoTo Err_cmdAutocad statement... so I know that the VBA code is working just fine.
It is just something in the AutoCAD instance of the object that will not continue to run the script. The first line of the script is basically opening a file. Thus you see in the code listing below, right before you run the script, you are doing a filedia and then setting it to 0.
The next thing AutoCAD does is stop and place 'open' on one line and says it doesn't recognize the command. In this script the first line is something like open g:\pj\5500-50\mda\something.dwg
Now my first thought looking at this is hey I don't have any quotations around the path right? But there is something else to this...
In fact, if I type filedia or any other type of AutoCAD command it will not recognize them at all! I believe there is something else I must do besides just merely having Dim objDwg As AcadDocument / Set objDwg = New AcadDocument in order to bring up AutoCAD through VBA!
I can post the entire script but I doubt it will help any. Here is the URL to it below.
http://www.cadvault.com/forums/show...8635#post108635
This has to do with the ActiveX control object that is referenced in Access!
Has anyone here manipulated that before using VBA to run .scr scripts before? Should I use AcadApplication instead and if so what changes need to be made to duplicate the process?
Private Sub cmdAutocad_Click()
On Error GoTo Err_cmdAutocad
MsgBox "You're going to have to open AutoCAD manually - type 'filedia' then '1' - go to Tools - Run Script and find: " & txtNameFile
Exit Sub
Dim objDwg As AcadDocument
Set objDwg = New AcadDocument
objDwg.Activate
objDwg.SetVariable "FILEDIA", 0
objDwg.SendCommand "script" & vbCr & txtNameFile & vbCr
MsgBox "Script has been ran!"
Exit_cmdAutocad:
On Error Resume Next
Exit Sub
Err_cmdAutocad:
MsgBox "You must have Full AutoCAD to run this and under Tools - Options... you must have Single-drawing compatibility mode checked on!"
Call Error_Action(Err, Err.Description, "frmMainMenu @ cmdAutocad_Click")
Resume Exit_cmdAutocad
End Sub
It is just something in the AutoCAD instance of the object that will not continue to run the script. The first line of the script is basically opening a file. Thus you see in the code listing below, right before you run the script, you are doing a filedia and then setting it to 0.
The next thing AutoCAD does is stop and place 'open' on one line and says it doesn't recognize the command. In this script the first line is something like open g:\pj\5500-50\mda\something.dwg
Now my first thought looking at this is hey I don't have any quotations around the path right? But there is something else to this...
In fact, if I type filedia or any other type of AutoCAD command it will not recognize them at all! I believe there is something else I must do besides just merely having Dim objDwg As AcadDocument / Set objDwg = New AcadDocument in order to bring up AutoCAD through VBA!
I can post the entire script but I doubt it will help any. Here is the URL to it below.
http://www.cadvault.com/forums/show...8635#post108635
This has to do with the ActiveX control object that is referenced in Access!
Has anyone here manipulated that before using VBA to run .scr scripts before? Should I use AcadApplication instead and if so what changes need to be made to duplicate the process?
Private Sub cmdAutocad_Click()
On Error GoTo Err_cmdAutocad
MsgBox "You're going to have to open AutoCAD manually - type 'filedia' then '1' - go to Tools - Run Script and find: " & txtNameFile
Exit Sub
Dim objDwg As AcadDocument
Set objDwg = New AcadDocument
objDwg.Activate
objDwg.SetVariable "FILEDIA", 0
objDwg.SendCommand "script" & vbCr & txtNameFile & vbCr
MsgBox "Script has been ran!"
Exit_cmdAutocad:
On Error Resume Next
Exit Sub
Err_cmdAutocad:
MsgBox "You must have Full AutoCAD to run this and under Tools - Options... you must have Single-drawing compatibility mode checked on!"
Call Error_Action(Err, Err.Description, "frmMainMenu @ cmdAutocad_Click")
Resume Exit_cmdAutocad
End Sub