PDA

View Full Version : access macro from another workbook



benong
11-02-2011, 10:32 PM
hi,
i want to place a excel file 1 (contains macro) in a common network folder which others can access and execute the macro.
This macro1 will then access another excel file 2 which is located in my pc.
Others are not able to direct access to this excel file 2 in my pc.
How can i do so?

Many thanks for your guidance.

GTO
11-03-2011, 10:13 AM
hi,
i want to place a excel file 1 (contains macro) in a common network folder which others can access and execute the macro.
This macro1 will then access another excel file 2 which is located in my pc.
Others are not able to direct access to this excel file 2 in my pc.
How can i do so?

Many thanks for your guidance.

Presuming you mean that the second workbook is located on your machine's hard drive, how would this be able to happen?

Kenneth Hobs
11-03-2011, 03:57 PM
You will need that file opened to run it.
e.g.
Public Sub Main()
Dim FunctionName As String, Result As Double
FunctionName = "Fun2" ' Selected function
Result = Application.Run("'" & ThisWorkbook.FullName & "'!Module1." & FunctionName)
MsgBox Result
End Sub