PDA

View Full Version : [SOLVED] calling a macro from another workbook after opening the other workbook



jmutsche
11-15-2013, 12:34 PM
question: how would I go about running a macro named sub matt () it is located in the file that I have opened in this macro shown below, but I sure can't for the life of me figure out how to get it to run. that is step one once that is answered I have one more question.

thanks in advance.



Sub Macro1()
fname = "S:\Supervisor\Productivity\" & Year(Date) & "\" & Format(Date, "mmmm") & "\" & Format(Date, "mmmm") & " " & Year(Date) & " Productivity Tracking Results_V2.0.xlsm"
Debug.Print fname 'uncomment this line and check the flename in the immediate pane.
Workbooks.Open Filename:=fname, UpdateLinks:=0


wbname = ActiveWorkbook.Name


Sheets("Sheet1").Select


ThisWorkbook.Activate

Workbooks(wbname).Activate

End Sub

jmutsche
11-15-2013, 02:20 PM
Application.Run ("'" & wbname & "'!Dawn_UMWA")

SamT
11-16-2013, 12:43 PM
wbname.Dawn_UMWA

ArunkumarK
09-17-2015, 09:10 AM
Hi,
When I tried to run the code Application.Run ("'" & wbname & "'!Update"), I am getting an error stated as "Cannot run the macro. The macro may not be available in this workbook or all macros may be disabled." I can't understand the error because all the macros are already enabled moreover the file I am trying to run is also a macro enabled workbook.

Please reply me back if you have any idea.

Many thanks,
Arun

SamT
09-17-2015, 10:33 AM
Try
Sub Something()
'
'
'
wbName.Modulename.Update
'
'
End Sub
where Modulename might resemble "Module1" or "Sheet1" (the Codename of the Sheet) or even "ThisWorkbook"

ArunkumarK
09-18-2015, 01:05 AM
Thanks Sam for the reply.

But I have tried the suggested way already couple of times in both the ways as below and having the errors as.

1.
wbname = ActiveWorkbook.Name
wbname.Module1.Update
Error:Object required

2.
Set wb = Workbooks.Open(wbPath & sFile, Password:=pwd, UpdateLinks:=False)
wb.Module1.Update
Error:Object doesn't support this property or method.

Regards,
Arun



Try
Sub Something()
'
'
'
wbName.Modulename.Update
'
'
End Sub
where Modulename might resemble "Module1" or "Sheet1" (the Codename of the Sheet) or even "ThisWorkbook"

ArunkumarK
09-18-2015, 01:49 AM
Sam,

I have identified the issues, the name of the file already having the single quotes which seems to be the error. Its fixed now.
Thanks much for your time and the suggestions.

File name for your understanding: 040073_T42_PL_Aug'15

Regards,
Arun