Previous Thread

7/11/2006 6:24:50 AM    Running an Excel macro from Access problem
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



7/11/2006 8:14:59 AM    Re: Running an Excel macro from Access problem
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:

7/11/2006 9:48:05 AM    Re: Running an Excel macro from Access problem
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

7/11/2006 12:34:31 PM    Re: Running an Excel macro from Access problem
I think you may have wanted to rearrange those commands so that the .quit was 
 
before the "set = nothing" line. 
 
Huff wrote: 
 
-- 
 
Dave Peterson