I tried to execute a .vbs script to run macro inside Excel without opening the workbook. but when I open the workbook I found that nothing changed.
macro for changing column type from text to number percentage.
Public Sub updateColumnFormat()
'Disable screen update and calculation to improve the performance of import
Application.ScreenUpdating = False
Application.ScreenUpdating = True
Application.DisplayAlerts = False
Application.EnableEvents = False
Application.EnableCancelKey = True
Application.Calculation = False
Application.ScreenUpdating = False
Sheets("Status").Select
[B:B].Select 'Update data type from text to number of CreditLimit (Column B)
With Selection
.NumberFormat = "General"
.Value = .Value
End With
Selection.Style = "Percent"
Call Refreashstage
'Sheets("Status").Select
'Range("B3").Select
'Sheets("Sales").Select
On Error Resume Next
End Sub
Sub Refreashstage()
Sheets("Status").Select
Range("B3").Select
Sheets("FY21 Sales Forecast").Select
End Sub
.vbs script to execute macro without open the Excel
Set ObjExcel = CreateObject("Excel.Application")
objExcel.Application.Run "'C:\Users\NB\Desktop\test6.xlsm'!Module1.updateColumnFormat"
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing