creating a link to a application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to create a command button that will open a microsoft visio file
in Access. I am not sure on what command to use in the VBA code to make this
work. Making the command button is simple, but I am having trouble getting
the command button to link up with the program. I am trying really to use
the command button as a hyperlink (for a lack of a better word) to launch the
Microsoft visio file. Any ideas on I can do this?

thanks,
 
Application.FollowHyperlink "Path to file"

Like:

Application.FollowHyperlink "D:\My Documents\Visio File.vsd"


Chris Nebinger
 
Here's sample code that will open a WORD file. I don't have VISIO so
you'll have to snoop around to tweak it.
At minimum, you'll have to make the following changes...

1. change the CreateObject() function to work with VISIO - try
VISIO.Application
2. change the appWord.Documents statements if VISIO uses a different
collection for VISIO docs.

If you open the VBA editor for VISIO and go into HELP, you should be
able to find everything that you need by looking at the OBJECT MODEL
REFERENCE for VISIO. To get the answer to item #2 above, start by
looking at the APPLICATION object.


Dim appWord As Object
Dim varTemplate

Set appWord = CreateObject("Word.Application")
appWord.Visible = True

varTemplate = DLookup("txtNameSignTemplate", "tblMasterAccounts",
"[lngMasterAccountId] = [Forms]![frmReservations]![cboMasterAccount]")

If IsNull(varTemplate) Then
varTemplate = "Standard Name Sign.doc"
End If

varFullFileName = "C:\Documents and Settings\dch3\My
documents\willard madison\name signs\" & varTemplate
appWord.Documents.Open FileName:=varFullFileName
appWord.Documents(varTemplate).FormFields("nameSign").Result =
[Forms]![frmReservations]![txtNameSign]

Set appWord = Nothing
 
If you are only opening the file, and do not need a reference to it,
either FollowHyperlink or Shell are better options.

Shell "winword.exe ""C:\Documents and Settings\dch3\My
documents\willard madison\name signs\" & varTemplate & """"

Best:

Application.FollowHyperlink "C:\Documents and Settings\dch3\My
documents\willard madison\name signs\" & varTemplate


Chris Nebinger
 
Back
Top