Make onTimer wait until Excel finish database request?

  • Thread starter news.stofanet.dk
  • Start date
N

news.stofanet.dk

Hi all,

I have a spreadsheet that:
1) Every minute connect to a database importing data to Excel (no vba)
2) Every half hour save the spreadsheet to disk (vba onTimer event)

Sometimes the two "timers" collide bringing up a popup, asking if the user
will save now, or wait for the update. It stops everything.

Is there a way to avoid the popup? - It does not matter if the current
database update or save is canceled.
 
V

Vergel Adriano

In the OnTimer event, check first if the database query is refreshing or not
before saving the workbook. Assuming the database query is in Sheet1, and
that there is only one query, then in the onTimer event in VBA

If Not Sheet1.QueryTables(1).Refreshing then
thisworkbook.save
End If


Another way is to disable the automatic refresh of the database query and
let your VBA code do the refresh. In this way, you have full control of both
events.
 
N

news.stofanet.dk

thanks a lot, I'll give it a try.

--
Hans


Vergel Adriano said:
In the OnTimer event, check first if the database query is refreshing or
not
before saving the workbook. Assuming the database query is in Sheet1, and
that there is only one query, then in the onTimer event in VBA

If Not Sheet1.QueryTables(1).Refreshing then
thisworkbook.save
End If


Another way is to disable the automatic refresh of the database query and
let your VBA code do the refresh. In this way, you have full control of
both
events.
 

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