Link to home
Start Free TrialLog in
Avatar of MikeMcEvoy
MikeMcEvoyFlag for United States of America

asked on

VBA to Import Module

Hello,

I just need a simple vba script that will import module "C:\Documents and Settings\mm31896\Desktop\Module4.bas".

I've tried a few examples that I found by searching previous answers but they all seem to kick out run time errors. Any help would be greatly appreciated.
'This is an example of attempt that kicks out a runtime error.
 
Sub AddBasFile()
ThisWorkbook.VBProject.VBComponents.Import _
Filename:="C:\Documents and Settings\mm31896\Desktop\Module4.bas"
End Sub

Open in new window

Avatar of Saurabh Singh Teotia
Saurabh Singh Teotia
Flag of India image

I believe this is what you are looking for a good read about how to the same...

http://www.cpearson.com/Excel/vbe.aspx

Saurabh...
There is probably something wrong with the import file. Can you post it? Do you already have a module with the same name? What is the error?

Kevin
Avatar of MikeMcEvoy

ASKER

The import file seems to be ok.  It actually contains code that you helped me with a few days ago (It's attached).
The Error is "Method VBProject' of object'_Workbook' failed"
I looked at Chip Pearson's site and have not been able to figure it out.

Module4.txt
ASKER CERTIFIED SOLUTION
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect Thanks!  
Saurabh thanks for your suggestion as well.