Export Import Modules File Name error

G

Guest

Hi
I have been able to automate the export of module however I am having
problems importing the module.

The following is the code I currently have to Import but when I run it I get
a file name error and I am not sure why.

Any help would be great.

Public Sub AddModules()
Dim vbproject As vbproject
Dim vbcomp, vbcomp1, vpcom2, vpcomp3, vpcomp4, vpcomp5 As VBComponent
Set vbproject = ThisWorkbook.vbproject
Set vbcomp = ThisWorkbook.vbproject.vbcomponents.Import("G:\Merch
Services\Advertising\Macro\Module3.das")
End Sub
 
C

Chip Pearson

Noemi,

The exported file will have a "bas" extension, not a "das" extension.
Correct the name of the file in the Import statement.

Also, the line of code

Dim vbcomp, vbcomp1, vpcom2, vpcomp3, vpcomp4, vpcomp5 As VBComponent

is not doing what you think it is. It is NOT declaring all the variables as
VBComponent. It declares vbcomp, vbcomp1, vpcom2, vpcomp3, and vpcomp4 as
Variant types, and only vpcomp5 As VBComponent.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)
 
G

Guest

Hi Chip
Thanks for the info.

Would you happen to know why the remove module code doesn't work until your
program stops running.

What I mean is the removing of a module is required before the workbook is
email however the modules are not removed when I open up the emailed workbook.

Is there a way around to make sure it does perform the task of removing the
modules.

Thanks
Noemi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top