Thread: Query Tables
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Query Tables

the query itself has .Backgroundquery to true

in my experience
the refresh with bgqry argument false will NOT override it :(
(certainly when it hasn't executed before)

so what you do:
qt.backgroundquery = false
qt.refresh
ws.protect

the sheet is protected only when control is returned to the running
procedure e.g. ADO's STATE is DONE.

what would you expect to happen when the qt autorefreshes?
OR when you try to protect a sheet while ado's state is 'fetching'

conclusion:
the backgroundrefresh CANNOT en NEVER be true on protected sheets.
unless you fiddle with the settings till kingdom come...and you're sure
that the query under ALL circumstances:
will return the same number of fields and records.
will never OVERRIDE the cells, but UPDATE the cells.
preserveformatting is true
the table's cells are UNLOCKED
etc etc.

solution:
execute the queries on UNPROTECTED (but VERYHIDDEN?) sheets
get the data from there.



you'll need code needs to refresh
ws unprotect
qt.refresh
ws.protect



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Dale Marques" wrote:

.FieldNames = False
.RefreshStyle = xlOverwriteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = False
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery = False
.SavePassword = True
.SaveData = True
End With
Worksheets("Customer").Protect DrawingObjects = True,
contents = True, Scenarios = True
End Sub