http://www.mrexcel.com/forum/excel-q...pen-excel.html

I would like to run the following VBS to run my VBA below.

Dim args, objExcel

Set args = WScript.Arguments
Set objExcel = CreateObject("Excel.Application")

objExcel.Workbooks.Open args(0)
objExcel.Visible = True

objExcel.Run DHCPub, args(1)

objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close(0)
objExcel.Quit

VBA code I would like to run:

Sub DHCPub()

' DHC Macro
'

'

    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    ChDir ActiveWorkbook.Path & "\Data"
    
    
    
    'This is the part the get's the raw network data
    Application.Calculation = xlCalculationManual
        
    Call LastModifiedFileDHCDashboard
    
    Application.Calculation = xlCalculationAutomatic
    
    Application.Calculate
If Not Application.CalculationState = xlDone Then
    DoEvents
End If
 
 
    'This is the part the get's the raw network data

   Application.Calculation = xlCalculationManual
        
   Call LastModifiedFileDHCDashboardCampInfo

   Application.Calculation = xlCalculationAutomatic
        
Application.Calculate
If Not Application.CalculationState = xlDone Then
    DoEvents
End If
    
    'Update Date To Today
    Windows("DHC Master With Macros.xlsm").Activate
    Sheets("Network").Select
    Range("L1").Select
    ActiveCell.FormulaR1C1 = "=TODAY()"
    Range("L1").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

Application.Calculate
If Not Application.CalculationState = xlDone Then
    DoEvents
End If


    'Refresh facebook data
    Sheets("Social From Web").Select
    Range("A44").Select
    Selection.QueryTable.Refresh BackgroundQuery:=False
    'ActiveWorkbook.RefreshAll
    'With ActiveWorkbook.Connections("Connection")
    '    .Name = "Connection"
    '    .Description = ""
    'End With
    
    Application.Calculate
If Not Application.CalculationState = xlDone Then
    DoEvents
End If
 
    'Check if Social Worked
    Sheets("Social From Web").Select
     If IsEmpty(Range("A46")) Then
        MsgBox ("The Social Data Isn't Working Right")
    Else


    Sheets("Network").Select
    ActiveSheet.ListObjects("Network").AutoFilter.ApplyFilter
    Sheets("Master").Select
    ActiveSheet.ListObjects("Master").AutoFilter.ApplyFilter


Application.Calculate
If Not Application.CalculationState = xlDone Then
    DoEvents
End If

    Application.ScreenUpdating = True
    Application.DisplayAlerts = True

    ActiveWorkbook.Save
    ChDir _
    ActiveWorkbook.Path & "\" & MonthName(Month(Date)) & "\"
    ActiveWorkbook.SaveAs filename:= _
        ActiveWorkbook.Path & "\" & MonthName(Month(Date)) & "\" & "DHC" & Format$(Date, "yyyymmdd")
   
   Application.Calculate
If Not Application.CalculationState = xlDone Then
    DoEvents
End If
   
   Sheets("Social").Select
   
   Call CDO_Mail_DHC_JACOB
 

ActiveWindow.Close False

Workbooks.Open filename:= _
       "C:\Users\UserName\Google Drive\1 Daily Health Check\DHC Master With Macros.xlsm"


End If
   
  
End Sub
I have been running the following through task scheduler to no avail.

Program to run:cscript
Arguments""C:\Users\William\Google Drive\1 Daily Health Check\myScript.vbs" "C:\Users\William\Google Drive\1 Daily Health Check\DHC Master With Macros.xlsm" B

It opens my file and and says that it ran in task scheduler but doesn't run the macro.