Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Returning the name of a module
I have a collection of "utility" modules that I wish to be able to import
into a number of workbooks, and then run. Below is the code I wished to use to do this: Option Explicit Sub Add_Modules() Dim wbName Dim wkBk As Workbook Dim modName Dim i As Integer Dim j As Integer Dim module As String wbName = Application.GetOpenFilename(Title:="Select Files", MultiSelect:=True) modName = Application.GetOpenFilename(Title:="Select Modules to Add", MultiSelect:=True) For i = LBound(wbName) To UBound(wbName) Set wkBk = Workbooks.Open(wbName(i)) For j = LBound(modName) To UBound(modName) Call InsertVBComponent(wkBk, modName(j)) module = ? ' This is where I'm stuck... Application.Run (wkBk.Name & "!" & module) Next j Next i End Sub InsertVBComponent is a sub which imports the module named. The trouble I am having is in retrieving the name of the module in order to run the macro in it. The modules all contain one macro, named the same as the module name. For instance, Reset.bas is as follows: Attribute VB_Name = "Reset" Option Explicit Sub Reset() Dim linkArr Dim i As Integer Dim newLink As String linkArr = ThisWorkbook.LinkSources For i = 1 To UBound(linkArr) newLink = Replace(linkArr(i), Application.StartupPath, "P:\CASE\MIPROJ") ThisWorkbook.ChangeLink linkArr(i), newLink Next i End Sub One approach I have considered taking is to use the VB_Name constant - does anyone know how to retrieve this from the module? -- There are 10 types of people in the world - those who understand binary and those who don't. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Returning a value forom a Module to a Userform | Excel Programming | |||
code in module A to not execute a Worksheet_SelectionChange sub of another module | Excel Discussion (Misc queries) | |||
Run worksheet module code from workbook module? | Excel Programming | |||
Calls from sheet module to ThisWorkbook module | Excel Programming | |||
Variable from a sheet module in a class module in XL XP | Excel Programming |