Script not calling second VBA after _close

Script not calling second VBA after _close

Anonymous
Not applicable
718 Views
16 Replies
Message 1 of 17

Script not calling second VBA after _close

Anonymous
Not applicable
Hi, chaps.

I'm having problems calling VBA functions from a script:

Public Sub BTissued1()
MsgBox "1a"
ThisDrawing.Close
MsgBox "1b"
End Sub

Public Sub BTissued2()
MsgBox "2"
End Sub

-vbarun BTissued1
-vbarun BTissued2

(There's a space at the end of each line in the script.)

When I run the script I get "1a" displayed and the file closes; I then get "1b" but that's it. If I take "ThisDrawing.Close" away from BTissued1 I get all MsgBoxes.

(FYI, the reason I'm using a script is because in my full routine I'll be running a LISP routine between BTissued1 and BTissued2.)

I've tried the script:

(alert "1")
_close y
(alert "2")

but to no avail. Something similar worked in 2007 but has something changed in 2008?

S
0 Likes
719 Views
16 Replies
Replies (16)
Message 2 of 17

Anonymous
Not applicable
try placing a line like:
On Error Resume Next

as the first line of each of your subs... and do a thisdrawing.open ... before you make a msgbox call...

Are both of those subs saved in the same file?
0 Likes
Message 3 of 17

Anonymous
Not applicable
rudderdl,

No change I'm afraid.

S
0 Likes
Message 4 of 17

Anonymous
Not applicable
A command line to receive the command from the script is required.
If the first macro closes the drawing then the command to run the
second macro has no place to go.
0 Likes
Message 5 of 17

Anonymous
Not applicable
Even if there's a blank drawing still open?
0 Likes
Message 6 of 17

Anonymous
Not applicable
In your script - try calling the VBA macro in the following format (this will avoid any and all reload errors...):

(setq MyDVB ("c:\FullPath\DVBfile.dvb!ModuleName.SubName"))
(command "vbarun" MyDVB)
0 Likes
Message 7 of 17

Anonymous
Not applicable
Ok, I'll give it a bash...
0 Likes
Message 8 of 17

Anonymous
Not applicable
Mea culpa. It seems that the script is tied to the command line of
the drawing that started it - which makes sense now that I think
about it.
0 Likes
Message 9 of 17

Anonymous
Not applicable
That was going to be my next line of attack (honest). It seemed that whenever a close (VBA or Script) occurred the script stopped.

Fingers crossed...
0 Likes
Message 10 of 17

Anonymous
Not applicable
Fingers broken!

I've simplified this and taken out any reference to VBA for the time bean. Just plain ole script.

_open*"G:\5-2.dwg"
_line*90,500*940,540*
_qsave
_close
_line*90,500*940,540*

(The *s represent spaces in the actual script.)

I have a drawing open, 5-1.dwg. I run the script: it opens 5-2.dwg, draws a line, saves, closes, but doesn't draw the line in the original file, 5-1. (I've tried a space after _close but that just calls _script again.)

When my VBAs didn't work I was 'happy'. Now that a simple script doesn't work I'm upset. Am I a div? Help, please.

S
0 Likes
Message 11 of 17

Anonymous
Not applicable
When you are closing your file... is there another drawing still open behind it?
0 Likes
Message 12 of 17

Anonymous
Not applicable
Yep, 5-1.dwg. It's this one that I want to draw the second line in.
0 Likes
Message 13 of 17

Anonymous
Not applicable
Post your whole script file along with the dwg's in a zip file...
0 Likes
Message 14 of 17

Anonymous
Not applicable
Ok-dokey.
0 Likes
Message 15 of 17

Anonymous
Not applicable
;;; Try this...
_open
"G:\5-1.dwg"
_line 90,500 940,540

_qsave
_close
_open
"G:\5-2.dwg"
_line 90,500 940,540

_qsave
_close

;;Worked for me...
0 Likes
Message 16 of 17

Anonymous
Not applicable
Ok, thanks for that. Slightly modified,

_open "G:\5-1.dwg"
_line 90,500 940,540
_qsave
_close
_open "G:\5-2.dwg"
_line 90,500 940,540
_qsave
_close

works ok. But what if the second drawing is already open? The first _close this time seems to terminates the script and the line isn't drawn nor the drawing closed...?

_open "G:\5-1.dwg"
_line 90,500 940,540
_qsave
_close
_line 90,500 940,540
_close
0 Likes
Message 17 of 17

Anonymous
Not applicable
use lsp n the script to verify if the drawing is open...
Scripts are static otherwise (make sure the dwg is closed)
0 Likes