Chandni Kapoor
New Member
- Joined
- Aug 4, 2023
- Messages
- 1
- Office Version
- 2010
- Platform
- Windows
Can you please help me. I tried to save my excel file to the defined location. My code is working fine (Excel file copied to the define location successfully) but whenever i tried to open excel file. it gives an error (file is locked for editing). somehow VBA Excel File staying open in the background. I need to go to the taskbar & End task to open file. Still not able to find Where I am lagging. Please give your valuable feedback. Thanks in advance.
VBA code given below
Dim xlWb As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.DisplayAlerts = false
Set xlWb = xlApp.Workbooks.open("C:\Users\Public\LUM\DATALOG\Template\Report.xlsm")
newxlName = "C:\Users\Public\LUM\DATALOG\Report\Report_" & "_GENERATED_ON_" & Format(Now(), "dd_mm_yyyy")& "_" & Format(TimeValue(NOW()),"hh_nn_ss") & ".xlsm"
xlWb.saveas (newxlName)
xlApp.Workbooks.Saved = True
xlApp.Workbooks.Close
xlApp.quit
Set xlApp = Nothing
VBA code given below
Dim xlWb As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.DisplayAlerts = false
Set xlWb = xlApp.Workbooks.open("C:\Users\Public\LUM\DATALOG\Template\Report.xlsm")
newxlName = "C:\Users\Public\LUM\DATALOG\Report\Report_" & "_GENERATED_ON_" & Format(Now(), "dd_mm_yyyy")& "_" & Format(TimeValue(NOW()),"hh_nn_ss") & ".xlsm"
xlWb.saveas (newxlName)
xlApp.Workbooks.Saved = True
xlApp.Workbooks.Close
xlApp.quit
Set xlApp = Nothing