Hi,
Could anyone please help me figure out what is wrong with below VBScripting and how do I correct it?
It meant to
1) Open excel -- works
2) Refresh all data -- works
3) Remove external connection -- Dont work
4) Save as new file without any external connection -- Dont work due to 3rd step
Set oExcel = CreateObject("Excel.Application")
oExcel.Application.Visible = True
oExcel.DisplayAlerts = False
oExcel.AskToUpdateLinks = False
oExcel.AlertBeforeOverwriting = False
Set oWorkbook = oExcel.Workbooks.Open("file path.xlsx")
oWorkbook.RefreshAll
oExcel.ActiveWorkbook.Connections("connection name").Delete
oExcel.Activeworkbook.SaveAs "NewFileName_"& _
MyDateFormat &".xlsx"
oExcel.Activeworkbook.Close
oExcel.Quit
WScript.Quit
Could anyone please help me figure out what is wrong with below VBScripting and how do I correct it?
It meant to
1) Open excel -- works
2) Refresh all data -- works
3) Remove external connection -- Dont work
4) Save as new file without any external connection -- Dont work due to 3rd step
Set oExcel = CreateObject("Excel.Application")
oExcel.Application.Visible = True
oExcel.DisplayAlerts = False
oExcel.AskToUpdateLinks = False
oExcel.AlertBeforeOverwriting = False
Set oWorkbook = oExcel.Workbooks.Open("file path.xlsx")
oWorkbook.RefreshAll
oExcel.ActiveWorkbook.Connections("connection name").Delete
oExcel.Activeworkbook.SaveAs "NewFileName_"& _
MyDateFormat &".xlsx"
oExcel.Activeworkbook.Close
oExcel.Quit
WScript.Quit