ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Export Import Modules File Name error (https://www.excelbanter.com/excel-programming/375447-export-import-modules-file-name-error.html)

Noemi

Export Import Modules File Name error
 
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:\Mer ch
Services\Advertising\Macro\Module3.das")
End Sub


Chip Pearson

Export Import Modules File Name error
 
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)




"Noemi" wrote in message
...
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:\Mer ch
Services\Advertising\Macro\Module3.das")
End Sub




Noemi

Export Import Modules File Name error
 
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

"Chip Pearson" wrote:

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)




"Noemi" wrote in message
...
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:\Mer ch
Services\Advertising\Macro\Module3.das")
End Sub






All times are GMT +1. The time now is 12:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com