Programming with events in VBA
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Programming with events in VBA

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
fatorial
Guest





Posted: Fri Mar 18, 2005 2:48 am    Post subject: Programming with events in VBA Reply with quote

How can I do to load a macro with events automatically? I maked a macro with beginsave event and this one only works if I write the code into AutoCAD Object folder in the IDE.

This is the code:

Private Sub AcadDocument_BeginSave(ByVal FileName As String)
Call AutoDWF
MsgBox "O DWF has create successful! "
End Sub
Public Sub AutoDWF()

Dim objPlot As Object
Set objPlot = ThisDrawing.Plot

Dim blnRet As Boolean
Dim sDWFFile As String
Dim sPlotDriver As String
sDWFFile = "c:\ari\Facility01.dwf"
sPlotDriver = "c:\ari\DWF6 ePlot.pc3"
blnRet = objPlot.PlotToFile(sDWFFile, sPlotDriver)
End Sub

thanks!
Ari

Back to top
GTVic
Guest





Posted: Fri Mar 18, 2005 4:15 am    Post subject: Re: Programming with events in VBA Reply with quote

I believe you could load the macro using LISP and put that LISP code in the AcadDoc.lsp file to load automatically with each drawing.
Back to top
Mike Tuersley
Guest





Posted: Fri Mar 18, 2005 10:01 am    Post subject: Re: Programming with events in VBA Reply with quote

Create a project called ACAD.DVB. In it, create a STARTUP sub. Next make
sure that you have the dvb in a folder in your support path along with an
ACSII text file named ACAD.RX that has one line of code:

ACVBA.ARX - for 2004+
ACADVBA - for 2000-2002

When AutoCAD starts, it'll look for acad.rx which will initialize vba
within AutoCAD. Next, AutoCAD will load the acad.dvb and run whatever is in
the startup sub. For events, just include their programming as a part of
acad.dvb and they will activate whwn the file loads.

As for GTVic's comment, you could resort to lisp but why mix programming
languages when you don't need to.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...

Back to top
Ed Jobe
Guest





Posted: Fri Mar 18, 2005 9:11 pm    Post subject: Re: Programming with events in VBA Reply with quote

One tiny correction Mike, the sub must be called ACADStartup (unless they
changed it in 2006?).

--
----
Ed
----
"Mike Tuersley" <mtuersley_NOT_@rand.com> wrote in message
news:o4meqtb2z9vc$.1fiaqcol2a1qe$.dlg@40tude.net...
Quote:
Create a project called ACAD.DVB. In it, create a STARTUP sub. Next make
sure that you have the dvb in a folder in your support path along with an
ACSII text file named ACAD.RX that has one line of code:

ACVBA.ARX - for 2004+
ACADVBA - for 2000-2002

When AutoCAD starts, it'll look for acad.rx which will initialize vba
within AutoCAD. Next, AutoCAD will load the acad.dvb and run whatever is
in
the startup sub. For events, just include their programming as a part of
acad.dvb and they will activate whwn the file loads.

As for GTVic's comment, you could resort to lisp but why mix programming
languages when you don't need to.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Back to top
Mike Tuersley
Guest





Posted: Fri Mar 18, 2005 9:59 pm    Post subject: Re: Programming with events in VBA Reply with quote

Nope, it's still the same. Thanks for the correction, Ed! One of those,
it's late and my mind is asleep posts.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Back to top
Ed Jobe
Guest





Posted: Fri Mar 18, 2005 11:35 pm    Post subject: Re: Programming with events in VBA Reply with quote

Don't ya just hate that? :-) Keep up the good work!

--
----
Ed
----
"Mike Tuersley" <mtuersley_NOT_@rand.com> wrote in message
news:10rx1f7806gv1$.1sb1v0t4rox76$.dlg@40tude.net...
Quote:
Nope, it's still the same. Thanks for the correction, Ed! One of those,
it's late and my mind is asleep posts.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB