Jump to content

VBA object problems


dbroada

Recommended Posts

We currently have a mixture of AutoCADs in the office. We all had ACAD2011 on XP but there are now 2 machines with ACAD2013 on XP and one ACAD2013 on 64 bit Win7.

 

I am in the process of changing my VBA routines to VB.Net but naturally, the main one is still only working in VBA. And this is where the problem comes. The boss' machine (the 64 bit Win 7) doesn't like the line..

 

Dim PlineObj As AcadLWPolyline

It says it doesn't know what an AcadLWPolyline is, where my machine is quite happy.

 

Can anybody shed some light on how to coax the newest installation into running my code? The rest of the office are due to move on to ACAD2013/Win7 and it would be nice to get it working before too long. I'm not sure when I will be moved but currently I am probably going to be last.

 

====================

 

the message I get is "Object or library not found", but the references look the same - he is a long way from me and I keep forgetting by the time I walk from one machine to the other.

Edited by dbroada
more info given
Link to comment
Share on other sites

  • Replies 24
  • Created
  • Last Reply

Top Posters In This Topic

  • dbroada

    12

  • Tyke

    10

  • BlackBox

    3

Top Posters In This Topic

Posted Images

I have several VBA Macros that use LW polylines and they work on all versions of AutoCAD from 2002 to 2013 XP to W7, 32 and 64 bit. We have a single machine that is 64 bit W7 running AutoCAD 2013 and that causes problems sometimes. It automatically adds a reference to the "AutoCAD 2013 Type Library" to the macro. In itself tjat is not a problem, but as our macros are located on the server and not locally on each machine it means no one else can use the macros any more. My solution was for the one machine to have the macros saved locally on the machine and not let it access the macros on the server and we have had no problems since then.

 

Try adding a reference und Tools > References to "AutoCAD 2013 Type Library" and see if that works. You will have to do that on his machine.

Link to comment
Share on other sites

the "AutoCAD 2013 Type Library" is referenced on his machine,as it is on mine. They both appear to be loaded from C:\Program Files\Common Files\Autodesk Shared\acax.19enu [something that disappears off the side of the box but is probably .tlb].

 

However, I have just noticed that the VBA project is not saved on either C: drive. I don't know how that happened as I normally give each machine it own acad.dvb file. I'll try saving the dvb locally again and see what happens.

Link to comment
Share on other sites

When you added the Library (assembly) reference to your VB.NET project, did you make sure to set Copy Local = False?

Link to comment
Share on other sites

When you added the Library (assembly) reference to your VB.NET project, did you make sure to set Copy Local = False?
I think so. This problem is with a VBA project but there will be my VB.Net project already running. Will they influence each other?
Link to comment
Share on other sites

I think so. This problem is with a VBA project but there will be my VB.Net project already running. Will they influence each other?

 

My mistake, Dave... I incorrectly thought this was about .NET, and not VBA (I've been sick for days, and am forcing myself to work today to keep my word about getting a submittal out... It appears that I left my wit at home)... In any event, if VBA's anything like .NET it should be fine, as the code only needs to Interface with the Objects, Modules, etc., but again, I am no VBA guy.

 

I defer to whatever Tyke says. :)

Link to comment
Share on other sites

I think this is going to be "one of those things". I don't get time to check these things out sensibly and just have to try sticky tape to keep it running. The second Win 7/Acad2013 has just arrived in the office so we can see whether that one plays nicely or not.

Link to comment
Share on other sites

A dumb man doesn't know how smart he is; a smart man knows how smart he isn't. :beer:

 

And which category are you placing me in? ;) It would be best if you didn't answer that one :lol:

Link to comment
Share on other sites

I have several VBA Macros that use LW polylines and they work on all versions of AutoCAD from 2002 to 2013 XP to W7, 32 and 64 bit. We have a single machine that is 64 bit W7 running AutoCAD 2013 and that causes problems sometimes. It automatically adds a reference to the "AutoCAD 2013 Type Library" to the macro. In itself tjat is not a problem, but as our macros are located on the server and not locally on each machine it means no one else can use the macros any more. My solution was for the one machine to have the macros saved locally on the machine and not let it access the macros on the server and we have had no problems since then.

 

Try adding a reference und Tools > References to "AutoCAD 2013 Type Library" and see if that works. You will have to do that on his machine.

our second installation with Win 7 happened today, and it doesn't work there either. :(

 

It is our subbie's machine and she is not working Wednesday so I can get on the machine and look more closeley then. Saving the DVB locally hasn't made any difference.

 

Where does your Win7 one add the reference?

Link to comment
Share on other sites

our second installation with Win 7 happened today, and it doesn't work there either. :(

 

It is our subbie's machine and she is not working Wednesday so I can get on the machine and look more closeley then. Saving the DVB locally hasn't made any difference.

 

Where does your Win7 one add the reference?

 

If you open the VBA Manager, load the project and then open the VBAIDE and the project. When you are in one of the modules got to the menu Tools > References and a window will appear. When I look in there the last item that is ticked is the 'AuoCAD 2013 Type Library'. If it does not appear, scroll down the list until you find it and then tick it. Under the ticked items at the top all other items are ordered alphabetically, so its easy enough to find. AutoCAD 2012 does it too on W7 the machines here, okay 2012 is not an issue with you Dave, just for completeness. Also on "011 and earlier the W7 machines don't add their type libraries! Strange!

 

What happens if you 'step through' the macro instead of running it?

Best of luck with it, it looks like you are in for an interesting day.

Link to comment
Share on other sites

What happens if you 'step through' the macro instead of running it?

I have probably declared this wrong but it used to work... In the declarations area i have

Dim PlineObj As AcadLWPolyline

and this is where it the problem occurs. I can't step through as it falls over on the very first line. If I comment out that line it falls over as the first line that calls PlineObj.

 

This is my screen shot but I did check that machine 1 was the same. I will check the other tomorrow.

 

Reference.JPG

Link to comment
Share on other sites

I don't know if this will cause problems elsewhere with the rest of your code but have you tried declaring your polyline object so:

 

Dim PlineObj As AcadPolyline

This would then be a 2D ployline which carries a bigger overhead than a LW polyline, but it could work. Declaring a LW polyline on my W7 machines is not a problem and the only differences I can see between my machines and yours is that mine run a German OS and a German version of AutoCAD whereas yours are English. But I can't imagine that should make any difference.

 

B

Link to comment
Share on other sites

OK, thanks Tyke - I will look tomorrow on Jo's machine. I could well be on here quite a bit! :)

 

I will try that on mine now and see what happens but I'm off to a recording of QI this afternoon so won't spend too long on it.

Link to comment
Share on other sites

a British TV show that you must be sadly missing in Germany. Hosted by Stephen Fry with two teams "interesting" people. Somewhere between a chat show and a comedy quiz show - sort of "Have I got news for you" (if you have seen that) - which coincidentally I am off to see a recording of on Thursady.

 

Anyway, I looked at changing the polyline but there were too many minor changes necessary that I couldn't get very far without spending much time on it. I will print out the code before I try again! One of the problems was my original code was sloppy and the "On error resume next" line was masking all sorts of problems. :rofl:

Link to comment
Share on other sites

Nope, QI is something that I haven't seen and that we don't get here in Germany, but I will have a look and see if I can see it on my iPad. But on the other hand, Strphen Fry and "Have I got news for you" are a couple of my favorites. Have a good time and give my regards to Heather.

Link to comment
Share on other sites

Good morning Tyke, guess what?

 

I got on Jo's machine this morning, commented out a couple of "on error resume next" lines and the routine fell over where I was trying to add a UCS component. I commented them out, uncommented the "On Error" lines and it looks like it is now behaving. Just have to check that mine is the same....

 

Jo's machine and the boss' machine work today. If they don't work tomorrow hopefully it is just a matter of finding the right folder to put the DVB file in.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...