Error using VBA in Excel to open Civil 3D 2011 with a borrowed license
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have been searching for a solution to this problem for a couple of days and coming up empty so far. I have a bit of VBA code in in excel that works just fine in the office, but fails and returns errors when I am working with a borrowed license. I am not a programmer and this is my first foray into VBA. I have picked up most by hunting around the net and reading other code I have found. If someone knows a way to make this work with a borrowed license as well as a non borrowed license that would be much appreciated.
My goal with this portion of the Code is simply to open a standard drawing from a specified location, or use the existing standard drawing if it is already open.
the snippet of the code that I am using and works in the office is as follows:
Sub Export_to_AutoCAD()
Dim Acad As AcadApplication
On Error Resume Next
Set Acad = GetObject(, "AutoCAD.Application")
On Error GoTo 0
If Acad Is Nothing Then
Set Acad = New AcadApplication
End If
Acad.Visible = True
'Open specific Standard Drawing in order to fill in table with data from this spreadsheet
Dim NewFile As AcadDocument
Dim DwgFilePath As String
Dim DwgName As String
Dim DwgLocation As String
Dim DwgReadOnly As Boolean
Worksheets("Setup").Activate
DwgFilePath = Range("B2")
DwgName = Range("B4")
DwgLocation = DwgFilePath & "\" & DwgName
DwgReadOnly = True
On Error Resume Next
Set NewFile = Acad.Documents.Open(DwgLocation, DwgReadOnly)
On Error GoTo 0
If NewFile Is Nothing Then
Errormessage:
If NewFile = "False" Then End
MsgBox ("Could not find the required spreadsheet. Ensure the path and filename are correct" & vbCr & DwgFilePath & DwgName & vbCr & "Rename or relocate the required drawing file as needed.")
End
Acad.Quit
Acad = Nothing
NewFile = Nothing
End If