Unloading a program using the UnloadDVB method.

Unloading a program using the UnloadDVB method.

Anonymous
Not applicable
516 Views
9 Replies
Message 1 of 10

Unloading a program using the UnloadDVB method.

Anonymous
Not applicable
Can anyone help with this one?
I am trying to use the "UnloadDVB" method to unload the program from memory. Don't ask me why, but this is the method I have to use, I'll explain later if you care. Unfortunately upon running the code using unloadDVB, I was given an error:

"Problem in unloading DVB file."

Here is the code I am using to unload the program:

Dim strFilename As String
strFilename = "NPG_Tools_2000.dvb"
UnloadDVB strFilename

This code follows all other lines of code in the command button it is assigned to. It is run after clicking a command button that does a few other things and is then supposed to run the above code to unload the project.

In the help file it says: "* Note: If the DVB is already open, there will be an error when trying to unload the ." But it does not say how to correct it. How do I "close" the dvb file before unloading it? Thanx for any help.

Rob
0 Likes
517 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable
You can't unload the DVB if the DVB is running.
Meaning if you execute a macro within that DVB and the macro tries to unload the
DVB that is running your macro you will get an error. If you would like to
unload the DVB file that is currently being used you must do it by SendCommand.
Example below:

 

Public Sub MyMacro()

 

ThisDrawing.SendCommand "vbaunload
DVBFileName "

End Sub

 

Hopefully this helps.

 

Bryan

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Can
anyone help with this one?
I am trying to use the "UnloadDVB" method to
unload the program from memory. Don't ask me why, but this is the method I
have to use, I'll explain later if you care. Unfortunately upon running the
code using unloadDVB, I was given an error:

"Problem in unloading DVB file."

Here is the code I am using to unload the program:

Dim strFilename As String
strFilename = "NPG_Tools_2000.dvb"

UnloadDVB strFilename

This code follows all other lines of code in the command button it is
assigned to. It is run after clicking a command button that does a few other
things and is then supposed to run the above code to unload the project.

In the help file it says: "* Note: If the <insert dvb filename here>
DVB is already open, there will be an error when trying to unload the
<insert dvb filename here>." But it does not say how to correct it. How
do I "close" the dvb file before unloading it? Thanx for any help.

Rob

0 Likes
Message 3 of 10

Anonymous
Not applicable
You probably cannot run
face="Times New Roman" size=3>the "UnloadDVB"
method
from within the project you are trying to
unload.  The example you found runs a Sub in a first application which, in
turn,  loads a second, separate .DVB, then runs a macro in that second
.DVB, then runs the UnloadDVB method of the first application with the second
.DVB as the target.  If you want to experiment with unloading the running
project, try moving the call to UnloadDVB up to an Application level event,
maybe AppDeactivate().  I haven't tried this, it's just a
guess.

--
John Goodfellow
irtf'nm
use 'microtouch' in address to email



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Can
anyone help with this one?
I am trying to use the "UnloadDVB" method to
unload the program from memory. Don't ask me why, but this is the method I
have to use, I'll explain later if you care. Unfortunately upon running the
code using unloadDVB, I was given an error:

"Problem in unloading DVB file."

Here is the code I am using to unload the program:

Dim strFilename As String
strFilename = "NPG_Tools_2000.dvb"

UnloadDVB strFilename

This code follows all other lines of code in the command button it is
assigned to. It is run after clicking a command button that does a few other
things and is then supposed to run the above code to unload the project.

In the help file it says: "* Note: If the <insert dvb filename here>
DVB is already open, there will be an error when trying to unload the
<insert dvb filename here>." But it does not say how to correct it. How
do I "close" the dvb file before unloading it? Thanx for any help.

Rob

0 Likes
Message 4 of 10

Anonymous
Not applicable
Hi Brian,

Thanx for the input, but I have tried this. Unfortunately the SendCommand seems to have problems with spaces in the directory names. Here is the directory name I am using.

ThisDrawing.SendCommand "_vbaunload" & vbCr & "x:/cad standards/programs/visual basic/acad2000/npg_tools_2000.dvb" & vbCr

I have no option to change it either. I can't seem to figure this out. Dosen't anyone have a way to unload a DVB file from the code???? Thanx fot the help.

Rob
0 Likes
Message 5 of 10

Anonymous
Not applicable
You might try building the folder path using a "Chr(32)" instead of the
SPACE key.
str = "_vbaunload" & vbCr & "x:/cad" & Chr(32) &
"standards/programs/visual"...
ThisDrawing.SendCommand str
--
John Goodfellow
irtf'nm
use 'microtouch' in address to email

"NHLFAN" wrote in message
news:ef5d77e.2@WebX.SaUCah8kaAW...
Hi Brian,
Thanx for the input, but I have tried this. Unfortunately the SendCommand
seems to have problems with spaces in the directory names. Here is the
directory name I am using.
ThisDrawing.SendCommand "_vbaunload" & vbCr & "x:/cad
standards/programs/visual basic/acad2000/npg_tools_2000.dvb" & vbCr
I have no option to change it either. I can't seem to figure this out.
Dosen't anyone have a way to unload a DVB file from the code???? Thanx fot
the help.
Rob
0 Likes
Message 6 of 10

Anonymous
Not applicable
Rob,

 

Instead of using
size=3>"x:/cad standards/programs/visual basic/acad2000/npg_tools_2000.dvb" for
the path and file name use this:

"x:/cadsta~1/progra~1/visual~1/acad2000/npg_tools_2000.dvb"

 

This is basically the DOS or 16-bit path to that file. The problem with
using folders or files over 8 characters long is that AutoCAD uses the short 8
character filenames then truncates it down to 8 characters like I have down
above. I didn't change the filename. You might be able to get a way with using
the filname the way it is. I would suggest using no more then 8 characters in
your filenames that way you know for sure that you won't run into this problem
in the future. Hope this helps...

 

Bryan


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hi
Brian,

Thanx for the input, but I have tried this. Unfortunately the SendCommand
seems to have problems with spaces in the directory names. Here is the
directory name I am using.

ThisDrawing.SendCommand "_vbaunload" & vbCr & "x:/cad
standards/programs/visual basic/acad2000/npg_tools_2000.dvb" & vbCr

I have no option to change it either. I can't seem to figure this out.
Dosen't anyone have a way to unload a DVB file from the code???? Thanx fot the
help.

Rob

0 Likes
Message 7 of 10

Anonymous
Not applicable
AAAARRRRRGGGGG!!!

Whew, Ok now I feel better... well not really, it still dosen't work. Ok here is my problem now:

When using the Str = Chr(32).... method I get the following error:

"Compile Error: argument not optional"

what do I need to do here? Typically you just put a set in front of it right? You would think it would be so cut and dry. How can it possibly be this difficult to unload a dang program??? I also tried using the shortened names with the tilde (~) symbol and that did not work either. It broke the names up as it did when they were spaces. I am about to give up!

Rob
0 Likes
Message 8 of 10

Anonymous
Not applicable
Well, I can't get SendCommand to stop choking on the spaces in the path
either. It's about this time I ask myself, "Do I REALLY need to do this?"
So, I'll ask you, too. What are you doing? Why do you need to unload the
project? There's probably another solution.
--
John Goodfellow
irtf'nm
use 'microtouch' in address to email

"NHLFAN" wrote in message
news:ef5d77e.5@WebX.SaUCah8kaAW...
AAAARRRRRGGGGG!!!
Whew, Ok now I feel better... well not really, it still dosen't work. Ok
here is my problem now:
When using the Str = Chr(32).... method I get the following error:
"Compile Error: argument not optional"
what do I need to do here? Typically you just put a set in front of it
right? You would think it would be so cut and dry. How can it possibly be
this difficult to unload a dang program??? I also tried using the shortened
names with the tilde (~) symbol and that did not work either. It broke the
names up as it did when they were spaces. I am about to give up!
Rob
0 Likes
Message 9 of 10

Anonymous
Not applicable
John,

Here is my reasoning behind unloading the project. I am trying to run the program across several workstations. 12 to be exact. The program runs when the user clicks on the toolbutton I have created for it. I do not want the user to be able to edit the code in any way or even see the code for that matter. So if for some reason there is a error, it would cease running and unload the code and not give the user an error and allow them the option to "debug" the program. Some would not mess with it, but others would love the chance. I know I can password protect it, and maybe that is the option, but at times I have had problems with password protecting the code. I geuss I could simply have the program load when autocad starts and unload when it exits. The only problem is I don't want to have to use profiles or switches in the icons etc... Can you load it and unload it from lisp? If so how hard would it be to load it when ACAD starts and unload it when Acad closes? Now that I said that, I geuss it has no choice but to unload when Acad closes. Anyway, what do you think? Thanx again,

Rob
0 Likes
Message 10 of 10

Anonymous
Not applicable
Hi Rob,

OK.  A VBA application breaks to the
debug/trace window when there is no error handler set.  If you include an
error handler in each of your Sub/Function's, then you maintain control over
what happens after the error is encountered.  Next, if you attach a small
VBA loader module to the toolbar button, and let it load (Application.LoadDVB)
the main module(s) from a separate .DVB when the button is selected, then you
would be able bail out of the main module and return to the loader for any
reason, including an error.  From there, you could run the
Application.UnloadDVB method on the main module .DVB, since it has finished
running.  Here's an error handler skeleton.

 

Sub Main()
' Dim whatever
On Error Goto
Err_Main    ' activate error handling
 ' working
code       ' any error causes an immediate
jump to
Err_Main:
Exit_Main:          '
exit point for Sub
 ' do cleanup
 Exit
Sub
Err_Main:
  Select Case Err.Number
  Case <known
error #>
   ' fix
it
   Resume         '
continue running app.
  Case Else
   ' can't fix
it
   Resume Exit_Main    ' go directly to
the cleanup & exit (return to caller)
  End Select
End
Sub                      
' end Main()
--
John Goodfellow
irtf'nm
use 'microtouch' in
address to email


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
0 Likes