Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VBA to Import Module

Posted on 2008-10-15
5
Medium Priority
?
1,278 Views
Last Modified: 2012-05-05
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

0
Comment
Question by:MikeMcEvoy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 59

Expert Comment

by:Saurabh Singh Teotia
ID: 22724281
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...
0
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 22724307
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
0
 
LVL 2

Author Comment

by:MikeMcEvoy
ID: 22724481
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
0
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 2000 total points
ID: 22724719
I can import the module without issue.

Have you enabled access to the VBA project? The option is set on the Trusted Publishers tab of the Security dialog (Tools->Macros->Security, "Trust access to Visual Basic Project").

Kevin



0
 
LVL 2

Author Comment

by:MikeMcEvoy
ID: 22724769
Perfect Thanks!  
Saurabh thanks for your suggestion as well.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

596 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question