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, Consultant
Category: Programming
Satisfied Customers: 30254
Experience:  Programming and Network consultancy for 15+ years
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: 1 month ago.
Category: Programming
Expert:  The-PC-Guy replied 1 month 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 1 month 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...
after the macro is run the VBAProject -> Microsoft Excel Objects -> Modules contains
call me for more info(###) ###-####
Expert:  The-PC-Guy replied 1 month ago.

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

Expert:  Richard replied 1 month ago.

Hi there and welcome

This is the code you would need to use

Option Explicit

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