Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Excel automation problem

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 )


  #2   Report Post  
Posted to microsoft.public.excel.programming
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 )



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Excel automation problem

Arvi,
Apart from the fact that you are not opening this workbook, but getting a
reference to it after...
Using:
Set WB = Application.Workbooks.Open("MyFile.xls")
with Excel 2K, this dialog is not shown anyway.
If you to refresh each one or not depends on your requirement.
Dim QT as QueryTable
For each QT In WB.QueryTables
QT.refresh
....

NickHK

"Arvi Laanemets" wrote in message
...
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 )




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Excel automation problem

Thanks
The final version of script:


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
objXLBook.Sheets("Sheet1").QueryTables(1).Refresh
objXLBook.Sheets("Sheet2").QueryTables(1).Refresh
objXLBook.Sheets("Sheet3").QueryTables(1).Refresh
objXLBook.Sheets("Sheet4").QueryTables(1).Refresh
WScript.Sleep(10000)
objXLApp.DisplayAlerts=False
objXLApp.ActiveWorkbook.SaveAs(strPath & strBook)
objXLApp.DisplayAlerts=True

objXLApp.Quit


This script will run at every night on server. The workbook MyWorkbook.xls
resides on shared network resource, and users use 4 tables in it as a
datasource for various ODBC queries (original data location isn't accessible
for most of users).



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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 c++ automation problem. Ken Excel Worksheet Functions 0 January 9th 07 12:13 AM
Automation problem saving Excel as HTML. nicol Excel Programming 1 February 1st 06 10:16 AM
Excel Automation Problem With Add-Ins pagates Excel Programming 4 October 6th 05 05:18 PM
Problem in graph automation in excel. news.microsoft.com[_7_] Excel Programming 3 April 30th 05 06:02 AM
TypeConverter Excel-Automation problem Markus Excel Programming 0 August 23rd 04 11:17 AM


All times are GMT +1. The time now is 02:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"