automatic query refresh

G

Guest

I am using JAVA to retrieve data to an excel sheet.
The data is generated in the excel sheet but when I open that excel sheet a
message comes saying
"queries are used to import external data into an excel sheet but harmful
queries can be used to access confidential information or write info back to
the database."
"This workbook contains queries to external data that refresh sutomatically".
Can anyone tell me how to get rid of this message?
and
how to disable automatic query refresh in excel
 
N

Nick Hodge

Sid

Not sure what code you have, but this recorded in Excel sets the auto
refresh to false

With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=MS Access Database;DBQ=C:\DivCls.mdb;DefaultDir=C:\" _
), Array( _
"Access;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"
_
)), Destination:=Range("A1"))
.CommandText = Array( _
"SELECT qryNewDivCls.Div, qryNewDivCls.DivDesc, qryNewDivCls.Cls,
qryNewDivCls.ClsDesc" & Chr(13) & "" & Chr(10) & "FROM
`C:\Access\DivCls`.qryNewDivCls qryNewDivCls" _
)
.Name = "Query from MS Access Database"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False '<<<Here is the setting
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = False
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With




--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top