How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask Richard Your Own Question
Richard
Richard, Consultant
Category: Programming
Satisfied Customers: 36866
Experience:  Programming and Network consultancy for 15+ years
32989067
Type Your Programming Question Here...
Richard is online now
A new question is answered every 9 seconds

I need a macro to import all MODULES from a C: drive folder

Customer Question

I need a macro to import all MODULES from a C: drive folder into the active workbook
Submitted: 11 months ago.
Category: Programming
Expert:  The-PC-Guy replied 11 months ago.

what do you mean by modules.

if you could send an example file of what you are looking to do I will take a look at it tomorrow as it is late where I am

Customer: replied 11 months ago.
By Modules I mean...
VBAProject -> Microsoft Excel Objects -> Modules
I want to input all the Modules from a disc folder to the above Module folderthe disc folder contains...
Module3
Module20
Module23
after the macro is run the VBAProject -> Microsoft Excel Objects -> Modules contains
Module3
Module20
Module23
call me for more info(###) ###-####
Expert:  The-PC-Guy replied 11 months ago.

really not sure what you are getting at, so I will open it to other experts.

Expert:  Richard replied 11 months ago.

Hi there and welcome

This is the code you would need to use

Option Explicit
'http://www.tech-archive.net/Archive/Excel/microsoft.public.excel/2009-03/msg00695.html

Sub importBas()

Dim VBProj As Object 'VBIDE.VBProject
Dim myFileName As String

myFileName = "C:\folder\file.bas"

Set VBProj = Nothing
On Error Resume Next
Set VBProj = ActiveWorkbook.VBProject
On Error GoTo 0

If VBProj Is Nothing Then
MsgBox "Can't continue--I'm not trusted!"
Exit Sub
End If

VBProj.vbcomponents.Import myFileName

End Sub

This will import it into the current spreadsheet

Let me know if you have any problems please

Related Programming Questions