title: Run Excel macro without opening it
body: <p>I have a functionality where in I get CSV file as email attachment. I have to import that CSV file into Excel file, build SSRS report on that Excel file. I have written a macro to import data from CSV into Excel. But I want that Excel file should get populated with CSV data without opening because it is not convenient to open Excel file every time to get refreshed SSRS report. I have written VBS code also to run macro but it is not populating my Excel file.</p>
  
  <p>My Macro:</p>
  
  <pre><code>Sub getDataImported()
      Sheet11.Cells(1, 1).Resize(1, 3).EntireColumn.ClearContents
      MsgBox "Inside Macro"
      With Sheet11.QueryTables.Add(Connection:= _
          "TEXT;D:\Sample SSRS\power View\AlertHistory.csv", Destination:=Range("$A$1") _
          )
          .Name = "AlertHistory"
          .FieldNames = True
          .RowNumbers = False
          .FillAdjacentFormulas = False
          .PreserveFormatting = True
          .RefreshOnFileOpen = False
          .RefreshStyle = xlInsertDeleteCells
          .SavePassword = False
          .SaveData = True
          .AdjustColumnWidth = True
          .RefreshPeriod = 0
          .TextFilePromptOnRefresh = False
          .TextFilePlatform = 437
          .TextFileStartRow = 1
          .TextFileParseType = xlDelimited
          .TextFileTextQualifier = xlTextQualifierDoubleQuote
          .TextFileConsecutiveDelimiter = False
          .TextFileTabDelimiter = False
          .TextFileSemicolonDelimiter = False
          .TextFileCommaDelimiter = True
          .TextFileSpaceDelimiter = False
          .TextFileColumnDataTypes = Array(1, 1, 1)
          .TextFileTrailingMinusNumbers = True
          .Refresh BackgroundQuery:=False
      End With
  End Sub
  </code></pre>
  
  <p>My VBS:</p>
  
  <pre><code>Set objExcel = CreateObject("Excel.Application")
  objExcel.Application.Run "'D:\Sample SSRS\power View\AlertHistory.xlsm'!Module1.getDataImported"
  objExcel.DisplayAlerts = False
  objExcel.Application.Quit
  Set objExcel = Nothing
  </code></pre>