Trying to open a Workbook and a run a macro in that file

前端 未结 3 2078
谎友^
谎友^ 2020-12-06 20:14

I have a workbook which opens up another workbook (filename is based on a cell value) and then runs a macro called Single_sector within that file.

It opens the file

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-06 20:32

    Probably not very elegant but:

    Dim Location As String
    
    Location = "\\location\to\file.xlsm"
    
    Workbooks.Open(Location).RunAutoMacros (xlAutoOpen) 
    

    Where you have an Auto_Open Sub in your other excel file to handle the macros to run on your other spreadsheet

提交回复
热议问题