View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Papou Papou is offline
external usenet poster
 
Posts: 67
Default Excel automation problem

Hello
objXLBook.RefreshAll

HTH
Cordially
Pascal

"Arvi Laanemets" a écrit dans le message de news:
...
Hi

I want open an Excel workbook through vbscript from below. The workbook
contains 4 ODBC queries, which are refreshed on open. After some time, the
workbook is saved and closed. It all works OK, but is there a way to get
rid of message "This workbook contains queries to external data, that
refresh automatically. ....", with choices enable/disable refresh. Of
course I can check 'Enable automatic query refresh for all workbooks ...',
but I want the automatic refresh run without asking for this workbook
only! Is there some way to enforce this from vbscript - using some
parameters for Getobject() maybe? I don't want to have any code in
workbook at all, as then I have to cope with macro warning, and I don't
want to lower the security level - so an Open event is not an option -
then I better set all workbooks to be refreshed automatically.

********
Option Explicit

Dim objXLApp, objXLBook, strPath, strBook

strPath = "Drive:\Path\"
strBook = "MyWorkbook.xls"
Set objXLBook=GetObject(strPath & strBook)
Set objXLApp = objXLBook.Parent
objXLApp.Visible = True
objXLBook.Windows(1).Visible = True
WScript.Sleep(10000)
objXLApp.DisplayAlerts=False
objXLApp.ActiveWorkbook.SaveAs(strPath & strBook)
objXLApp.DisplayAlerts=True

objXLApp.Quit
*********


Thanks in advance!
--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )