Hi I'm trying to run the following code in an Access function in order to run an Excel macro. The problem I have is that I wish to close the excel workbook but with changes saved. If I add in the line 'objExcel.Save' before the close command it throws errors saving do you want to replace 'resume.xla'. 'objExcel.Workbooks.Save' doesn't seem to work either. How can I get the workbook to close with changes saved? Set objExcel = CreateObject("Excel.Application") objExcel.Workbooks.Open ("C:\[file path and name here].xls") objExcel.Visible = True objExcel.Run "Update" objExcel.Workbooks.Close objExcel.Quit Thanks in advance! Doug
Thanks Dave, worked a treat. Had to remove the final objExcel.Quit line, 'cos we'd already set objExcel to Nothing in the previous line, but after that it's all systems go again. Cheers. Dave Peterson wrote:
Set objExcel = CreateObject("Excel.Application") Set objWorkbook _ = objExcel.Workbooks.Open ("C:\[file path and name here].xls") objExcel.Visible = True objExcel.Run "Update" objWorkbook.close True 'savechanges:=true set objExcel = nothing Set objWorkbook = nothing objExcel.Quit Huff wrote: -- Dave Peterson
I think you may have wanted to rearrange those commands so that the .quit was before the "set = nothing" line. Huff wrote: -- Dave Peterson