If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Test if Acces file open

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-16-08, 17:10
JillB JillB is offline
Registered User
 
Join Date: Dec 2007
Posts: 48
Test if Acces file open

I am running an Excel VBA module which opens Access file and runs a VBA Access module.

The problem is as soon as the Access file opens, then Excel continues the next steps of the code which relate to copying the Access database.

I would like to halt the Excel code after the Access file is opened, detect if the Access file has been closed, and then let the Excel code continue.

Is this possible in Excel VBA?

All suggestions and poineters would be gratefully received

with thanks,

Jill


Code:
Dim objAccess_Tx_Master As Access.Application
Application.DisplayAlerts = False

Set objAccess_Tx_Master = CreateObject(TempFilePath) ' the local database copy
objAccess_Tx_Master.Visible = True

'*************************************
'DO ALL THE EDITING NOW ON THE DATABASE
'*************************************

'when editing completed, and DB file closed    <<< HOW TO DO THIS TEST?
myStr = MsgBox("Did you modify the database?", vbYesNo)
If myStr = vbYes Then
 MsgBox"This will copy the modified database back to another location"

Last edited by JillB; 01-16-08 at 17:11. Reason: typos
Reply With Quote
  #2 (permalink)  
Old 01-17-08, 10:21
Marvels Marvels is offline
Registered User
 
Join Date: Jul 2003
Location: Amsterdam, Nederland
Posts: 449
re

YOULL HAVE TO CHECK THIS BUT SHOULD BE ABOUT RIGHT

Set app = GetObject(, "Acces.Application")
If app Is Nothing Then
' Acces is not running, create new instance
Set app = CreateObject("Acces.Application")
app.Visible = True
End If

do until
if app.Visible = false
exit do
endif
loop
Reply With Quote
  #3 (permalink)  
Old 01-17-08, 17:52
JillB JillB is offline
Registered User
 
Join Date: Dec 2007
Posts: 48
This is quite clever, and so simple, like all good code. Many thanks Marvels
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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