Excel's vba works at home but not at work

Excel's vba works at home but not at work

Anonymous
Not applicable
717 Views
5 Replies
Message 1 of 6

Excel's vba works at home but not at work

Anonymous
Not applicable

Hi to all,

 

I've created a module with Excel's vba were data is copied to drawing in acad.

 

At home I have a student version of Acad 2014 and it works fine.

 

When I use the exact copy at work it gives me OLE errors.

 

Any ideas of how to sort it out?

 

CODE:

Dim acadApp As AcadApplication
Dim acadDoc As AcadDocument
Dim acadPol As AcadLWPolyline
Dim dblCoordinates() As Double

'Check if AutoCAD is open.
On Error Resume Next
Set acadApp = GetObject(, "AutoCAD.Application")
On Error GoTo 0

'If AutoCAD is not opened create a new instance and make it visible.
If acadApp Is Nothing Then
Set acadApp = New AcadApplication 'PROG STOPS HERE
acadApp.Visible = True
End If

'Check if there is an active drawing.
On Error Resume Next
Set acadDoc = acadApp.ActiveDocument
On Error GoTo 0

'No active drawing found. Create a new one.
If acadDoc Is Nothing Then
Set acadDoc = acadApp.Documents.Add
acadApp.Visible = True
End If

 

Regards

Kenneth

0 Likes
Accepted solutions (1)
718 Views
5 Replies
Replies (5)
Message 2 of 6

Ed__Jobe
Mentor
Mentor

After you try to get an app from the ROT using GetObject() and it fails, you should use CreateObject(), not the New keyword.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 6

Anonymous
Not applicable

Sorry, but didn't get!

 

What exactly i have to do. I'm not new to excell vba but totally to acad

 

Also work's version is LT. Is it maybe the problem?

 

Ken

0 Likes
Message 4 of 6

Ed__Jobe
Mentor
Mentor

Set acadApp = New AcadApplication 'PROG STOPS HERE

Set acadApp = CreateObject(, "AutoCAD.Application")

 

Yes, LT is the other problem. It doesn't support VBA.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 5 of 6

Anonymous
Not applicable

Hi Ed,

 

So basically I'm doomed 360. VBA is in excel and not actually in Acad. Will it work if I use your tip?

 

Ken

 

0 Likes
Message 6 of 6

Ed__Jobe
Mentor
Mentor
Accepted solution

No. Even if you successfully set acadapp, you won't be able to execute the rest of your code. LT doesn't do lisp or vba. No way around it. Like you said, doomed 360. Sorry.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes