Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is Access or Word running

Status
Not open for further replies.

DocPoster

Technical User
Jun 10, 2004
6
US
I'm writing a VBA class module that both Access 2000 and Word 2000 will use. How do I detect if it's Access or Word that's running the code? I want to conditionally compile code based on which one is running it.

Code:
#If (Access is running) Then
Dim shRegistry As New WshShell
strInstallPath = shRegistry.RegRead(strInstallSettings & "\Install_Path")
Set shRegistry = Nothing
#Else
'This command works in Word but not Access
strInstallPath = System.PrivateProfileString("", strInstallSettings, "Install_Path")
#End If
 
Hi, DocPoster,

Probably lots of ways to do it... I think I would create a public string variable in your module, then set the value from the procedure in Word/Access that calls the function(s) in question. Then, of course, the function(s) in the module would need to test for the value of the variable and branch your code from that point.

HTH,

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top