Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Running an Excel macro from Access problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Huff - 11 Jul 2006 14:24 GMT
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
Dave Peterson - 11 Jul 2006 15:48 GMT
   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

> Hi
>
[quoted text clipped - 17 lines]
>
> Doug

Signature

Dave Peterson

Huff - 11 Jul 2006 16:14 GMT
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 - 11 Jul 2006 18:34 GMT
I think you may have wanted to rearrange those commands so that the .quit was
before the "set = nothing" line.

> Thanks Dave, worked a treat.
>
[quoted text clipped - 3 lines]
>
> Cheers.

Signature

Dave Peterson


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.