<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Removing the module using code! in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/removing-the-module-using-code/m-p/12470116#M1086</link>
    <description>&lt;P&gt;Yes, I never put code in a dwg. Run VBAMAN and you will see at the top of the dialog, the embedded project will be listed. Click on the Extract button and save it to a *.dvb file. Make sure that the folder you save it to is listed in the Options&amp;gt;File&amp;gt;Support File Search Path and Options&amp;gt;Files&amp;gt;Trusted Folders.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you just need to load the dvb when you want to use the commands you created. For me, the best way is to create a cuix with the toolbars or ribbon commands you will use. Then create a *.mnl file with the same name as your cuix. The mnl contains lisp. You can use the following lisp to load your dvb when the menu loads.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="lisp"&gt;;;; Ed's toolbox
;;; support functions for EngineeringUtilities.cuix routines
;;;________________________________________

(setq supdir "c:\\AcadCustom\\support_GS\\")

;;; *********************
;;; setq global variables
;;; *********************
(vl-load-com)
;;; get the application object
(setq *acadObj* (vlax-get-acad-object))

;;; *********************
;;; load vba modules used by engr.mnu
;;; *********************
(vl-vbaload (strcat supdir "Toolbox.dvb"))

;;    array of command name strings your dvb has.
;;    i.e. the names of all the Public Sub methods.
(setq CommandList
       (list
	 "EraseClouds"	
	 "PrintSchedule"
	 "SaveAll"	
	 "SetViewportScale"	
	)
)

;;    make a defun for each command name
;;    commands  that will run in the document context
;;    This way you can run a command without the VBARUN command.
;;    It makes it easy to repeat the last command too, [Enter].
(foreach CommandName CommandList
  (eval
    (list 'defun
	  (read (strcat "C:" CommandName))
	  '()
	  (list 'vla-RunMacro *AcadObj* CommandName)
	  '(princ)
    )
  )
)

;;; *********************
;;; end loading engr.mnl
;;; *********************
(princ "\nEngineering Utilities Menu loaded")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Save the above lisp as yourcuixname.mnl. Change the path and filenames to match your setup. For further discussion, &lt;A href="https://forums.augi.com/showthread.php?55292-TIP-VBA-command-wrappers-for-lisp" target="_blank" rel="noopener"&gt;look here&lt;/A&gt;.&lt;/P&gt;</description>
    <pubDate>Mon, 01 Jan 2024 00:14:09 GMT</pubDate>
    <dc:creator>Ed__Jobe</dc:creator>
    <dc:date>2024-01-01T00:14:09Z</dc:date>
    <item>
      <title>Removing the module using code!</title>
      <link>https://forums.autodesk.com/t5/vba-forum/removing-the-module-using-code/m-p/12468821#M1083</link>
      <description>&lt;P&gt;I guess it's nice to remove the module from the file right after the job is done. I found these lines for Excel vba. of course it doesn't work in Autocad.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Application.DisplayAlerts = False
ActiveWorkbook.VBProject.VBComponents.Remove ActiveWorkbook.VBProject.VBComponents("Module1")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;So I tried many different efforts to make this work. I'm&amp;nbsp; Still searching... for example this didn't work:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;ThisDrawing.Application.VBComponents.Remove "Module1"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I remove my module at end of my code?&lt;/P&gt;</description>
      <pubDate>Sat, 30 Dec 2023 19:15:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/removing-the-module-using-code/m-p/12468821#M1083</guid>
      <dc:creator>abbas.baghernezhad</dc:creator>
      <dc:date>2023-12-30T19:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Removing the module using code!</title>
      <link>https://forums.autodesk.com/t5/vba-forum/removing-the-module-using-code/m-p/12468971#M1084</link>
      <description>&lt;P&gt;Why are you trying to do that?&lt;/P&gt;
&lt;P&gt;First, it only works if your vba is embedded in the dwg, not if you store your code in a dvb. Second, it doesn't unload the code from memory, it just deletes the module from your project, requiring you to save your project and thus you will lose your code for use the next time.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Dec 2023 21:20:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/removing-the-module-using-code/m-p/12468971#M1084</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2023-12-30T21:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Removing the module using code!</title>
      <link>https://forums.autodesk.com/t5/vba-forum/removing-the-module-using-code/m-p/12469235#M1085</link>
      <description>&lt;P&gt;Yes , I know what it does. I send my files to customers and they asking why my Dwgs have some macro in it. Extra clicks bothers them and they think it is a malware. So I have to remove the macro everytime.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there another way which the macro wouldn't be embedded in the file?&lt;/P&gt;</description>
      <pubDate>Sun, 31 Dec 2023 03:19:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/removing-the-module-using-code/m-p/12469235#M1085</guid>
      <dc:creator>abbas.baghernezhad</dc:creator>
      <dc:date>2023-12-31T03:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Removing the module using code!</title>
      <link>https://forums.autodesk.com/t5/vba-forum/removing-the-module-using-code/m-p/12470116#M1086</link>
      <description>&lt;P&gt;Yes, I never put code in a dwg. Run VBAMAN and you will see at the top of the dialog, the embedded project will be listed. Click on the Extract button and save it to a *.dvb file. Make sure that the folder you save it to is listed in the Options&amp;gt;File&amp;gt;Support File Search Path and Options&amp;gt;Files&amp;gt;Trusted Folders.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you just need to load the dvb when you want to use the commands you created. For me, the best way is to create a cuix with the toolbars or ribbon commands you will use. Then create a *.mnl file with the same name as your cuix. The mnl contains lisp. You can use the following lisp to load your dvb when the menu loads.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="lisp"&gt;;;; Ed's toolbox
;;; support functions for EngineeringUtilities.cuix routines
;;;________________________________________

(setq supdir "c:\\AcadCustom\\support_GS\\")

;;; *********************
;;; setq global variables
;;; *********************
(vl-load-com)
;;; get the application object
(setq *acadObj* (vlax-get-acad-object))

;;; *********************
;;; load vba modules used by engr.mnu
;;; *********************
(vl-vbaload (strcat supdir "Toolbox.dvb"))

;;    array of command name strings your dvb has.
;;    i.e. the names of all the Public Sub methods.
(setq CommandList
       (list
	 "EraseClouds"	
	 "PrintSchedule"
	 "SaveAll"	
	 "SetViewportScale"	
	)
)

;;    make a defun for each command name
;;    commands  that will run in the document context
;;    This way you can run a command without the VBARUN command.
;;    It makes it easy to repeat the last command too, [Enter].
(foreach CommandName CommandList
  (eval
    (list 'defun
	  (read (strcat "C:" CommandName))
	  '()
	  (list 'vla-RunMacro *AcadObj* CommandName)
	  '(princ)
    )
  )
)

;;; *********************
;;; end loading engr.mnl
;;; *********************
(princ "\nEngineering Utilities Menu loaded")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Save the above lisp as yourcuixname.mnl. Change the path and filenames to match your setup. For further discussion, &lt;A href="https://forums.augi.com/showthread.php?55292-TIP-VBA-command-wrappers-for-lisp" target="_blank" rel="noopener"&gt;look here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jan 2024 00:14:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/removing-the-module-using-code/m-p/12470116#M1086</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2024-01-01T00:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: Removing the module using code!</title>
      <link>https://forums.autodesk.com/t5/vba-forum/removing-the-module-using-code/m-p/12470966#M1087</link>
      <description>&lt;P&gt;It is wonderful... and complicated.&lt;/P&gt;&lt;P&gt;- I added the dvb folder to the lists.&lt;/P&gt;&lt;P&gt;- Changed the lisp to Mymacro.mnl with changing:&lt;/P&gt;&lt;P&gt;(setq supdir "D:\\Programing\\VBA\\AutoCAD")&lt;/P&gt;&lt;P&gt;(vl-vbaload (strcat supdir "Mymacro.dvb"))&lt;/P&gt;&lt;P&gt;- in CUI , I created a command named Mymacro with&lt;/P&gt;&lt;P&gt;Name:&amp;nbsp;Mymacro&lt;/P&gt;&lt;P&gt;what else?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jan 2024 18:57:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/removing-the-module-using-code/m-p/12470966#M1087</guid>
      <dc:creator>abbas.baghernezhad</dc:creator>
      <dc:date>2024-01-01T18:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Removing the module using code!</title>
      <link>https://forums.autodesk.com/t5/vba-forum/removing-the-module-using-code/m-p/12471062#M1088</link>
      <description>&lt;P&gt;If you create a ribbon panel in a new cuix, and name the cuix "MyMacro.cuix", and name the lisp MyMacro.mnl, Then when you load the cuix, the MyMacro.mnl will automatically load and then it loads the dvb used by your ribbon buttons.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jan 2024 21:01:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/removing-the-module-using-code/m-p/12471062#M1088</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2024-01-01T21:01:17Z</dc:date>
    </item>
  </channel>
</rss>

