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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create hyperlink 1

Status
Not open for further replies.

samotek

Technical User
May 9, 2005
197
BG

I my database i have a code that creates a word document. In this document i create a hyperlink to my database using Insert-hyperlink.Can i create the hyperlink in my fucntion by defining the path and the name of the database ?

Public Function MyNotes()
Dim appW As Object
Dim docW As Object
Dim nErr As Integer
Const strFile = "C:\Be\Notes.doc"
On Error Resume Next
Set appW = GetObject(, "Word.Application")
nErr = Err
On Error GoTo 0
If nErr Then
Set appW = CreateObject("Word.Application")
End If
' Does document exist?
If Dir(strFile) = "" Then
' If not, create it
Set docW = appW.Documents.Add
' And save it
docW.SaveAs strFile
Else
' If it does exist, open it
Set docW = appW.Documents.Open(strFile)
End If
appW.Visible = True
Set docW = Nothing
Set appW = Nothing
End Function


 
Code:
...
   appW.Visible = True
   docW.Hyperlinks.Add Anchor:=appW.Selection.Range, Address:=CurrentDb.Name, TextToDisplay:=CurrentDb.Name
   Set docW = Nothing
...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top