Hello,
How do i save without the prompt to save as every time i run my Vb script. I'd like it to automatically save into my existing workbook rather than open a new path or prompt me to save all the time.
Thanks
'Input Excel File's Full Path
ExcelFilePath = "C:\Users\Student\Desktop\Tester.xlsm"
'Input Module/Macro name within the Excel File
MacroPath = "Sheet1.refresh1"
'Create an instance of Excel
Set ExcelApp = CreateObject("Excel.Application")
'Do you want this Excel instance to be visible?
ExcelApp.Visible = True ' or False
'Prevent any App Launch Alerts (ie Update External Links)
ExcelApp.DisplayAlerts = False
'Open Excel File
Set wb = ExcelApp.Workbooks.Open(ExcelFilePath)
'Execute Macro Code
ExcelApp.Run MacroPath
'Reset Display Alerts Before Closing
ExcelApp.DisplayAlerts = True
'Open workbook; Run Macro; Save Workbook with changes; Close; Quit Excel
Set wbToRun = ExcelApp.Workbooks.Open(ExcelFilePath)
ExcelApp.Run MacroPath ' wbToRun.Name & "!" & MacroPath
wbToRun.Save
wbToRun.Close
ExcelApp.Quit
How do i save without the prompt to save as every time i run my Vb script. I'd like it to automatically save into my existing workbook rather than open a new path or prompt me to save all the time.
Thanks
'Input Excel File's Full Path
ExcelFilePath = "C:\Users\Student\Desktop\Tester.xlsm"
'Input Module/Macro name within the Excel File
MacroPath = "Sheet1.refresh1"
'Create an instance of Excel
Set ExcelApp = CreateObject("Excel.Application")
'Do you want this Excel instance to be visible?
ExcelApp.Visible = True ' or False
'Prevent any App Launch Alerts (ie Update External Links)
ExcelApp.DisplayAlerts = False
'Open Excel File
Set wb = ExcelApp.Workbooks.Open(ExcelFilePath)
'Execute Macro Code
ExcelApp.Run MacroPath
'Reset Display Alerts Before Closing
ExcelApp.DisplayAlerts = True
'Open workbook; Run Macro; Save Workbook with changes; Close; Quit Excel
Set wbToRun = ExcelApp.Workbooks.Open(ExcelFilePath)
ExcelApp.Run MacroPath ' wbToRun.Name & "!" & MacroPath
wbToRun.Save
wbToRun.Close
ExcelApp.Quit