Open Word Document On Network from Form

  • Thread starter Thread starter Denis Bisson via AccessMonster.com
  • Start date Start date
D

Denis Bisson via AccessMonster.com

Good day,

I have a résumé database (Access 2003). We are manually entering
qualifications and keywords based on the actual person’s electronic résumé,
and querying the data as to provide us with a ‘short list’ of possible
candidates.

Once we get this ‘short list’ we want to open the electronic résumé to see
further details. These résumés are located in a specific folder on a network
drive and are all named using the following convention: “Last Name, First
Name.doc”.

Having a hyperlink field for each person, and manually entering the network
address to their résumé seems inefficient. What code could I use to click on
a button (or something) on a form, whereby I can open the associated résumé
(Word document)?

Example of network address: \\G:\CompanyName\Résumés\
The form has LNm and FNm fields.

Thank you for your time and assistance.

Denis Bisson

--
DenBis
*Smile, it makes people wonder what you're up to....*


Message posted via AccessMonster.com
 
Hi Denis,
I have a similar situation, and use the following code. In a new module,
paste the following:
'=====================
Option Explicit

Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal Hwnd As Long, ByVal lpOperation _
As String, ByVal lpFile As String, ByVal lpParameters _
As String, ByVal lpDirectory As String, ByVal nShowCmd _
As Long) As Long

Global Const SW_SHOWNORMAL = 1

Function StartDoc(DocName As String)
On Error GoTo StartDoc_Error

StartDoc = ShellExecute(Application.hWndAccessApp, "Open", DocName, _
"", "C:\", SW_SHOWNORMAL)
Exit Function

StartDoc_Error:
MsgBox "Error: " & Err & " " & Error
Exit Function
End Function



Function FileExists(Filename As String) As Boolean
FileExists = (Dir(Filename) > "")
End Function

'=====================

Then in the OnClick of a button, use the following:


'=====================
Dim last As String
Dim first As String
last = Me.LNm
first = Me.FNm

StartDoc "\\G:\CompanyName\Résumés\" & last & first & ".doc"
'=====================
 
Assuming that the applicant's first and last names are stored in variables
strFirstNm and strLastNm, you should be able to use

Application.FollowHyperlink "\\G:\CompanyName\Résumés\" & strLastNm & ", "
& strFirstNm & ".doc"

If that doesn't work, check out the ShellExecute API, detailed in
http://www.mvps.org/access/api/api0018.htm at "The Access Web"
 
Susan and Doug,

Thank you both for your solutions. I had something similar to Doug's solution,
except that I was trying to use DoCmd.RunCommand accmdOpenHyperlink instead
of the "Application.FollowHyperlink" (of which I was unaware), which wasn't
working for me.

Cheers!

Denis
 
Back
Top