ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code Question (https://www.excelbanter.com/excel-programming/288843-code-question.html)

Mikk

Code Question
 
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?

acw[_2_]

Code Question
 
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?



All times are GMT +1. The time now is 07:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com