Solved

VBA to Import Module

Posted on 2008-10-15
5
1,245 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
  • 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 500 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now