Execution error

Execution error

Anonymous
Not applicable
1,107 Views
18 Replies
Message 1 of 19

Execution error

Anonymous
Not applicable
Why when I run my programs from a drop down menu do I get an "Execution
error" when it is done? But I can run it from the VBA Editor and it works
fine. The programs do run fine, I just get that error.
0 Likes
1,108 Views
18 Replies
Replies (18)
Message 2 of 19

Anonymous
Not applicable
David,
Your probably using an unnecessary "end" statement somewhere in your
program.
-Josh

"David M. Gardner" wrote:

> Why when I run my programs from a drop down menu do I get an "Execution
> error" when it is done? But I can run it from the VBA Editor and it works
> fine. The programs do run fine, I just get that error.
0 Likes
Message 3 of 19

Anonymous
Not applicable
Dear All,

 

If I execute my VBA from VBA Editor, autocad does
not show any message.

If I execute from AutoCAD from my custom menu :
[Test]^c^c^p-VBARUN;MyPrg.prg01

then it shows Execution error when I click exit
button :

Private Sub cmdExit_Click()
  
End
End Sub

Why? Is anyone can tell me?

 

 

Thanks in advance

 

 

Arno Weng

 
0 Likes
Message 4 of 19

Anonymous
Not applicable
Sorry, I have to tell you:

If I use vbaman -> run macro, it dose not show
the error message

If I use menu or command prompt to run the macro,
it will show the error message at command prompt after I finish the
macro.

 

Help!

 

Thanks

 

Arno Weng

 
0 Likes
Message 5 of 19

Anonymous
Not applicable
okay so i went to www.autojournal.net to get teh vba code for the freeware program. i followed the
instructions. so i have a dvb file that contains this;

Option Explicit
Public WithEvents ACADApp As AcadApplication ' Use with Application Event
Examples
Public myolapp As Object
Public myitem As Object
Public SALARYMANOPEN As Boolean
Public DOCUMENTNAME As String
Public REGVAL As Variant
Public FN
Sub AcadStartup()
' This example intializes the public variable (ACADApp) which will be
used
' to intercept AcadApplication Events
'
' The VBA WithEvents statement makes it possible to intercept an generic
object
' with the events associated with that object.
'
' Before you will be able to trigger any of the AcadApplication events,
' you will first need to run this procedure.

' We could get the application from the ThisDocument object, but that
would
' require having a drawing open, so we grab it from the system.
Set ACADApp = GetObject(, "AutoCAD.Application")
FN = GetVariable("DWGNAME")
Call ACADApp_EndOpen(FN)
End Sub


Private Sub ACADApp_BeginQuit(Cancel As Boolean)
If DOCUMENTNAME = "" Then End
myitem.Subject = DOCUMENTNAME
myitem.StopTimer
myitem.Save
SALARYMANOPEN = False
End Sub


Private Sub ACADApp_EndOpen(ByVal FileName As String)
If SALARYMANOPEN = True Then
myitem.Subject = DOCUMENTNAME
myitem.StopTimer
myitem.Save
End If
Set myolapp = CreateObject("Outlook.Application")
Set myitem = myolapp.CreateItem(4)
myitem.Type = "AutoCAD"
myitem.StartTimer
SALARYMANOPEN = True
DOCUMENTNAME = FileName
End Sub

i saved it and when i try to autoload by adding (command "-vbarun" "ACADSTARTUP") to my acaddoc.lsp
i get this;

-vbarun
Command: Initializing VBA System...
Loading VBA startup file...
Macro name: ACADSTARTUP Execution error
Command:


why??
--
A2Ki Win98

Jonathan Baker
R&R Engineers-Surveyors, Inc.
Denver, Colorado
--
0 Likes
Message 6 of 19

Anonymous
Not applicable
I'm not sure about the problem but that code looks fishy to me.

First off, using GetObject is not a good idea since it will retrieve
only the first running instance of AutoCAD. In other words, the code
shown will not work for second and subsequent instances of AutoCAD.
Use ThisDrawing.Application instead.

Second, calling the EndOpen event from a startup macro is a tad
strange.

Third, you can only declare an object WithEvents in a class module or
a UserForm, not a standard module so the code should be instantiating
a class module that wraps the AcadApplication object rather than
trying to gain a reference to AutoCAD directly.

--
DSX Professional
The power of AutoCAD and Windows united
http://www.acadx.com


"Jon Baker" wrote in message
news:[email protected]...
> okay so i went to www.autojournal.net
0 Likes
Message 7 of 19

Anonymous
Not applicable
ummm okay...

thank you for your reply... but I no absolutely nothing about vba. what this is supposed to do is
log all the time I spend in a drawing with outlooks journal feature. if this will not work or if you
or anyone knows of a better way of doing this, please let me know.

--
A2Ki Win98

Jonathan Baker
R&R Engineers-Surveyors, Inc.
Denver, Colorado
--
"Frank Oquendo" wrote in message
news:[email protected]...
| I'm not sure about the problem but that code looks fishy to me.
|
| First off, using GetObject is not a good idea since it will retrieve
| only the first running instance of AutoCAD. In other words, the code
| shown will not work for second and subsequent instances of AutoCAD.
| Use ThisDrawing.Application instead.
|
| Second, calling the EndOpen event from a startup macro is a tad
| strange.
|
| Third, you can only declare an object WithEvents in a class module or
| a UserForm, not a standard module so the code should be instantiating
| a class module that wraps the AcadApplication object rather than
| trying to gain a reference to AutoCAD directly.
|
| --
| DSX Professional
| The power of AutoCAD and Windows united
| http://www.acadx.com
|
|
| "Jon Baker" wrote in message
| news:[email protected]...
| > okay so i went to www.autojournal.net
|
|
|
0 Likes
Message 8 of 19

Anonymous
Not applicable
any suggestions??

--
A2Ki Win98

Jonathan Baker
R&R Engineers-Surveyors, Inc.
Denver, Colorado
--
"Jon Baker" wrote in message
news:[email protected]...
| ummm okay...
|
| thank you for your reply... but I no absolutely nothing about vba. what this is supposed to do is
| log all the time I spend in a drawing with outlooks journal feature. if this will not work or if
you
| or anyone knows of a better way of doing this, please let me know.
|
| --
| A2Ki Win98
|
| Jonathan Baker
| R&R Engineers-Surveyors, Inc.
| Denver, Colorado
| --
| "Frank Oquendo" wrote in message
| news:[email protected]...
| | I'm not sure about the problem but that code looks fishy to me.
| |
| | First off, using GetObject is not a good idea since it will retrieve
| | only the first running instance of AutoCAD. In other words, the code
| | shown will not work for second and subsequent instances of AutoCAD.
| | Use ThisDrawing.Application instead.
| |
| | Second, calling the EndOpen event from a startup macro is a tad
| | strange.
| |
| | Third, you can only declare an object WithEvents in a class module or
| | a UserForm, not a standard module so the code should be instantiating
| | a class module that wraps the AcadApplication object rather than
| | trying to gain a reference to AutoCAD directly.
| |
| | --
| | DSX Professional
| | The power of AutoCAD and Windows united
| | http://www.acadx.com
| |
| |
| | "Jon Baker" wrote in message
| | news:[email protected]...
| | > okay so i went to www.autojournal.net
| |
| |
| |
|
0 Likes
Message 9 of 19

Anonymous
Not applicable
Hello again,

If I leave this line in my .dvb file, I get an execution error prompt on the
command line, but it seems to complete ok.

ThisDrawing.Application.UnloadDVB spath

any idea why?
Thanks in advance
Tom
0 Likes
Message 10 of 19

Anonymous
Not applicable
Are you trying to unload the dvb the code is running from?

"Tom Furness" wrote in message
news:[email protected]...
> Hello again,
>
> If I leave this line in my .dvb file, I get an execution error prompt on
the
> command line, but it seems to complete ok.
>
> ThisDrawing.Application.UnloadDVB spath
>
> any idea why?
> Thanks in advance
> Tom
>
>
0 Likes
Message 11 of 19

Anonymous
Not applicable
Yes. I wanted to load a dvb file, run the macro in it and then have it
unload itself.

"Kevin Terry" wrote in message
news:[email protected]...
> Are you trying to unload the dvb the code is running from?
>
> "Tom Furness" wrote in message
> news:[email protected]...
> > Hello again,
> >
> > If I leave this line in my .dvb file, I get an execution error prompt on
> the
> > command line, but it seems to complete ok.
> >
> > ThisDrawing.Application.UnloadDVB spath
> >
> > any idea why?
> > Thanks in advance
> > Tom
> >
> >
>
>
0 Likes
Message 12 of 19

Anonymous
Not applicable
Therein lies your problem, although it sounds like it's not a huge problem.
At least your code works. What's happening, is your code doesn't stop
running until it reaches an End or Exit statement. Your dvb (and therefore,
your code) is being unloaded before the code is finished running, so there
is an error. What I've done to avoid such errors is have one dvb always load
with autocad, and then load and unload other dvb's as needed from little
wrapper macros. I can give you an example if you want, otherwise you can
live with the error message.

Kevin

"Tom Furness" wrote in message
news:[email protected]...
> Yes. I wanted to load a dvb file, run the macro in it and then have it
> unload itself.
>
> "Kevin Terry" wrote in message
> news:[email protected]...
> > Are you trying to unload the dvb the code is running from?
> >
> > "Tom Furness" wrote in message
> > news:[email protected]...
> > > Hello again,
> > >
> > > If I leave this line in my .dvb file, I get an execution error prompt
on
> > the
> > > command line, but it seems to complete ok.
> > >
> > > ThisDrawing.Application.UnloadDVB spath
> > >
> > > any idea why?
> > > Thanks in advance
> > > Tom
> > >
> > >
> >
> >
>
>
0 Likes
Message 13 of 19

Anonymous
Not applicable
Kevin,
I would be VERY interested in seeing how you do that.
As my users run the various macros I have written, the ide get filled up. I
have been trying to find a way to control that.(like this unload the running
code) Sound like you have found a better way to do just that.
Tom


"Kevin Terry" wrote in message
news:[email protected]...
> Therein lies your problem, although it sounds like it's not a huge
problem.
> At least your code works. What's happening, is your code doesn't stop
> running until it reaches an End or Exit statement. Your dvb (and
therefore,
> your code) is being unloaded before the code is finished running, so there
> is an error. What I've done to avoid such errors is have one dvb always
load
> with autocad, and then load and unload other dvb's as needed from little
> wrapper macros. I can give you an example if you want, otherwise you can
> live with the error message.
>
> Kevin
>
> "Tom Furness" wrote in message
> news:[email protected]...
> > Yes. I wanted to load a dvb file, run the macro in it and then have it
> > unload itself.
> >
> > "Kevin Terry" wrote in message
> > news:[email protected]...
> > > Are you trying to unload the dvb the code is running from?
> > >
> > > "Tom Furness" wrote in message
> > > news:[email protected]...
> > > > Hello again,
> > > >
> > > > If I leave this line in my .dvb file, I get an execution error
prompt
> on
> > > the
> > > > command line, but it seems to complete ok.
> > > >
> > > > ThisDrawing.Application.UnloadDVB spath
> > > >
> > > > any idea why?
> > > > Thanks in advance
> > > > Tom
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 14 of 19

Anonymous
Not applicable
Tom,
replace my macro and dvb strings with yours and you should be all set.

Let me know if you need anything more,
Kevin


Public Sub BillOfMaterial()

'jproMainBom is the module name inside the dvb file to be opened
'NewBom is the macro name

Const sProject As String = "C:\JproTools\jproBOM.dvb"
Const sMacro As String = "jproMainBom.NewBom"

Dim vApp As VBIDE.VBE

Set vApp = Application.VBE

'open file
LoadDVB sProject

'macro to run
RunMacro sMacro

'close file
UnloadDVB sProject

Set vApp = Nothing

End Sub


"Tom Furness" wrote in message
news:[email protected]...
> Kevin,
> I would be VERY interested in seeing how you do that.
> As my users run the various macros I have written, the ide get filled up.
I
> have been trying to find a way to control that.(like this unload the
running
> code) Sound like you have found a better way to do just that.
> Tom
>
>
> "Kevin Terry" wrote in message
> news:[email protected]...
> > Therein lies your problem, although it sounds like it's not a huge
> problem.
> > At least your code works. What's happening, is your code doesn't stop
> > running until it reaches an End or Exit statement. Your dvb (and
> therefore,
> > your code) is being unloaded before the code is finished running, so
there
> > is an error. What I've done to avoid such errors is have one dvb always
> load
> > with autocad, and then load and unload other dvb's as needed from little
> > wrapper macros. I can give you an example if you want, otherwise you can
> > live with the error message.
> >
> > Kevin
> >
> > "Tom Furness" wrote in message
> > news:[email protected]...
> > > Yes. I wanted to load a dvb file, run the macro in it and then have it
> > > unload itself.
> > >
> > > "Kevin Terry" wrote in message
> > > news:[email protected]...
> > > > Are you trying to unload the dvb the code is running from?
> > > >
> > > > "Tom Furness" wrote in message
> > > > news:[email protected]...
> > > > > Hello again,
> > > > >
> > > > > If I leave this line in my .dvb file, I get an execution error
> prompt
> > on
> > > > the
> > > > > command line, but it seems to complete ok.
> > > > >
> > > > > ThisDrawing.Application.UnloadDVB spath
> > > > >
> > > > > any idea why?
> > > > > Thanks in advance
> > > > > Tom
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 15 of 19

Anonymous
Not applicable
Almost forgot, make sure you have the correct references set to:
Microsoft Visual Basic for Applications Extensibility 5.3 = vb6ext.olb

Kevin

"Tom Furness" wrote in message
news:[email protected]...
> Kevin,
> I would be VERY interested in seeing how you do that.
> As my users run the various macros I have written, the ide get filled up.
I
> have been trying to find a way to control that.(like this unload the
running
> code) Sound like you have found a better way to do just that.
> Tom
>
>
> "Kevin Terry" wrote in message
> news:[email protected]...
> > Therein lies your problem, although it sounds like it's not a huge
> problem.
> > At least your code works. What's happening, is your code doesn't stop
> > running until it reaches an End or Exit statement. Your dvb (and
> therefore,
> > your code) is being unloaded before the code is finished running, so
there
> > is an error. What I've done to avoid such errors is have one dvb always
> load
> > with autocad, and then load and unload other dvb's as needed from little
> > wrapper macros. I can give you an example if you want, otherwise you can
> > live with the error message.
> >
> > Kevin
> >
> > "Tom Furness" wrote in message
> > news:[email protected]...
> > > Yes. I wanted to load a dvb file, run the macro in it and then have it
> > > unload itself.
> > >
> > > "Kevin Terry" wrote in message
> > > news:[email protected]...
> > > > Are you trying to unload the dvb the code is running from?
> > > >
> > > > "Tom Furness" wrote in message
> > > > news:[email protected]...
> > > > > Hello again,
> > > > >
> > > > > If I leave this line in my .dvb file, I get an execution error
> prompt
> > on
> > > > the
> > > > > command line, but it seems to complete ok.
> > > > >
> > > > > ThisDrawing.Application.UnloadDVB spath
> > > > >
> > > > > any idea why?
> > > > > Thanks in advance
> > > > > Tom
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 16 of 19

Anonymous
Not applicable
Kevin,
If i might ask a couple of questions...

1. What purpose do the following lines serve?
Dim vApp As VBIDE.VBE
Set vApp = Application.VBE

After aquiring the object reference(vApp), it is never used?

2. Does this public sub (Public Sub BillOfMaterial()) go into the
autoloaded dvb file? as you develop more macros, do you just add more
public subs in the autoloaded dvb?

Thank you for all your time on this!

Tom

"Kevin Terry" wrote in message
news:[email protected]...
> Tom,
> replace my macro and dvb strings with yours and you should be all set.
>
> Let me know if you need anything more,
> Kevin
>
>
> Public Sub BillOfMaterial()
>
> 'jproMainBom is the module name inside the dvb file to be opened
> 'NewBom is the macro name
>
> Const sProject As String = "C:\JproTools\jproBOM.dvb"
> Const sMacro As String = "jproMainBom.NewBom"
>
> Dim vApp As VBIDE.VBE
>
> Set vApp = Application.VBE
>
> 'open file
> LoadDVB sProject
>
> 'macro to run
> RunMacro sMacro
>
> 'close file
> UnloadDVB sProject
>
> Set vApp = Nothing
>
> End Sub
>
>
> "Tom Furness" wrote in message
> news:[email protected]...
> > Kevin,
> > I would be VERY interested in seeing how you do that.
> > As my users run the various macros I have written, the ide get filled
up.
> I
> > have been trying to find a way to control that.(like this unload the
> running
> > code) Sound like you have found a better way to do just that.
> > Tom
> >
> >
> > "Kevin Terry" wrote in message
> > news:[email protected]...
> > > Therein lies your problem, although it sounds like it's not a huge
> > problem.
> > > At least your code works. What's happening, is your code doesn't stop
> > > running until it reaches an End or Exit statement. Your dvb (and
> > therefore,
> > > your code) is being unloaded before the code is finished running, so
> there
> > > is an error. What I've done to avoid such errors is have one dvb
always
> > load
> > > with autocad, and then load and unload other dvb's as needed from
little
> > > wrapper macros. I can give you an example if you want, otherwise you
can
> > > live with the error message.
> > >
> > > Kevin
> > >
> > > "Tom Furness" wrote in message
> > > news:[email protected]...
> > > > Yes. I wanted to load a dvb file, run the macro in it and then have
it
> > > > unload itself.
> > > >
> > > > "Kevin Terry" wrote in message
> > > > news:[email protected]...
> > > > > Are you trying to unload the dvb the code is running from?
> > > > >
> > > > > "Tom Furness" wrote in message
> > > > > news:[email protected]...
> > > > > > Hello again,
> > > > > >
> > > > > > If I leave this line in my .dvb file, I get an execution error
> > prompt
> > > on
> > > > > the
> > > > > > command line, but it seems to complete ok.
> > > > > >
> > > > > > ThisDrawing.Application.UnloadDVB spath
> > > > > >
> > > > > > any idea why?
> > > > > > Thanks in advance
> > > > > > Tom
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 17 of 19

Anonymous
Not applicable
Tom,
1. oops - sloppy code I guess, I must have started to do it a different
way...
2. yes, yes - although depending on what the routine does, I may put the
entire code into the autoloaded project (it takes a little time for this to
run, therefore I only use it for large applications).

no problem, that's what makes these ng's work (I've picked up all these tips
here myself, just pieced them together to work for me)
Kevin

"Tom Furness" wrote in message
news:[email protected]...
> Kevin,
> If i might ask a couple of questions...
>
> 1. What purpose do the following lines serve?
> Dim vApp As VBIDE.VBE
> Set vApp = Application.VBE
>
> After aquiring the object reference(vApp), it is never used?
>
> 2. Does this public sub (Public Sub BillOfMaterial()) go into the
> autoloaded dvb file? as you develop more macros, do you just add more
> public subs in the autoloaded dvb?
>
> Thank you for all your time on this!
>
> Tom
>
> "Kevin Terry" wrote in message
> news:[email protected]...
> > Tom,
> > replace my macro and dvb strings with yours and you should be all set.
> >
> > Let me know if you need anything more,
> > Kevin
> >
> >
> > Public Sub BillOfMaterial()
> >
> > 'jproMainBom is the module name inside the dvb file to be opened
> > 'NewBom is the macro name
> >
> > Const sProject As String = "C:\JproTools\jproBOM.dvb"
> > Const sMacro As String = "jproMainBom.NewBom"
> >
> > Dim vApp As VBIDE.VBE
> >
> > Set vApp = Application.VBE
> >
> > 'open file
> > LoadDVB sProject
> >
> > 'macro to run
> > RunMacro sMacro
> >
> > 'close file
> > UnloadDVB sProject
> >
> > Set vApp = Nothing
> >
> > End Sub
> >
> >
> > "Tom Furness" wrote in message
> > news:[email protected]...
> > > Kevin,
> > > I would be VERY interested in seeing how you do that.
> > > As my users run the various macros I have written, the ide get filled
> up.
> > I
> > > have been trying to find a way to control that.(like this unload the
> > running
> > > code) Sound like you have found a better way to do just that.
> > > Tom
> > >
> > >
> > > "Kevin Terry" wrote in message
> > > news:[email protected]...
> > > > Therein lies your problem, although it sounds like it's not a huge
> > > problem.
> > > > At least your code works. What's happening, is your code doesn't
stop
> > > > running until it reaches an End or Exit statement. Your dvb (and
> > > therefore,
> > > > your code) is being unloaded before the code is finished running, so
> > there
> > > > is an error. What I've done to avoid such errors is have one dvb
> always
> > > load
> > > > with autocad, and then load and unload other dvb's as needed from
> little
> > > > wrapper macros. I can give you an example if you want, otherwise you
> can
> > > > live with the error message.
> > > >
> > > > Kevin
> > > >
> > > > "Tom Furness" wrote in message
> > > > news:[email protected]...
> > > > > Yes. I wanted to load a dvb file, run the macro in it and then
have
> it
> > > > > unload itself.
> > > > >
> > > > > "Kevin Terry" wrote in message
> > > > > news:[email protected]...
> > > > > > Are you trying to unload the dvb the code is running from?
> > > > > >
> > > > > > "Tom Furness" wrote in message
> > > > > > news:[email protected]...
> > > > > > > Hello again,
> > > > > > >
> > > > > > > If I leave this line in my .dvb file, I get an execution error
> > > prompt
> > > > on
> > > > > > the
> > > > > > > command line, but it seems to complete ok.
> > > > > > >
> > > > > > > ThisDrawing.Application.UnloadDVB spath
> > > > > > >
> > > > > > > any idea why?
> > > > > > > Thanks in advance
> > > > > > > Tom
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 18 of 19

Anonymous
Not applicable
I am trying to run a macro from an icon on a toolbar. The macro runs fine
from the VBA manager, but when I try to run it from the icon, I get an
Execution error when the macro exits. Does anyone know what might be causing
this?

Thanks for any help!

--
Rod
0 Likes
Message 19 of 19

Anonymous
Not applicable
Somewhere in your code, you are probably using the End statement. Change it
to Exit.

--
--
Ed
--
"Rodney Crowley" wrote in message
news:[email protected]...
> I am trying to run a macro from an icon on a toolbar. The macro runs fine
> from the VBA manager, but when I try to run it from the icon, I get an
> Execution error when the macro exits. Does anyone know what might be
causing
> this?
>
> Thanks for any help!
>
> --
> Rod
>
>
0 Likes