Consulting

Results 1 to 7 of 7

Thread: calling a macro from another workbook after opening the other workbook

  1. #1
    VBAX Regular
    Joined
    Sep 2013
    Posts
    37
    Location

    calling a macro from another workbook after opening the other workbook

    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
    Last edited by SamT; 11-16-2013 at 12:43 PM. Reason: Asses Code Tags with # button

  2. #2
    VBAX Regular
    Joined
    Sep 2013
    Posts
    37
    Location
    Application.Run ("'" & wbname & "'!Dawn_UMWA")

  3. #3
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    wbname.Dawn_UMWA
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  4. #4
    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

  5. #5
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Try
    Sub Something()
    '
    '
    '
    wbName.Modulename.Update
    '
    '
    End Sub
    where Modulename might resemble "Module1" or "Sheet1" (the Codename of the Sheet) or even "ThisWorkbook"
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  6. #6

    Still not working.

    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


    Quote Originally Posted by SamT View Post
    Try
    Sub Something()
    '
    '
    '
    wbName.Modulename.Update
    '
    '
    End Sub
    where Modulename might resemble "Module1" or "Sheet1" (the Codename of the Sheet) or even "ThisWorkbook"

  7. #7
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •