Code Question

  • Thread starter Thread starter Mikk
  • Start date Start date
M

Mikk

I am not very knowledgeable about VBA code so here is my
question. I am trying to update an Excel file from a
command button. I am using the following code:
Set objXL = CreateObject("Excel.Application")
objXL.Visible = True
objXL.Workbooks.Open ("file")

The spreadsheet asks me if I want to update. I would
like to respond "yes", then save and exit the file all
without clicking a button. How would I finish this code?
 
Mikk

Try

Set objxl = CreateObject("Excel.Application")
objxl.Visible = True
objxl.Workbooks.Open FileName:="file", updatelinks:=True 'open file and update the links
objxl.Workbooks("aab.xls").Close savechanges:=True 'save the updated file
objxl.Application.Quit 'close the excel application


Tony

----- Mikk wrote: -----

I am not very knowledgeable about VBA code so here is my
question. I am trying to update an Excel file from a
command button. I am using the following code:
Set objXL = CreateObject("Excel.Application")
objXL.Visible = True
objXL.Workbooks.Open ("file")

The spreadsheet asks me if I want to update. I would
like to respond "yes", then save and exit the file all
without clicking a button. How would I finish this code?
 
Back
Top