link Access to Word documents

vanny

Registered User.
Local time
Yesterday, 21:12
Joined
Feb 18, 2006
Messages
76
Hi all..

I am new to Access and currently implementing a small company database.

Is it possible to link Access to Word documents?

I wish to create a button on a form that when clicked it opens the word document according to what have been selected in the combo box in the form.

thanks :o
 
Put this behind your command button or in the after update of your combo.
Code:
Dim strPath As String 'Declare Variable


strPath = Me.cboPath.Column(2) ' Name of your combo box and the column number (that holds your path e.g. C:\Temp\Test.doc


Call Shell("winword -o " & strPath, 1) ' Your variable goes in here
 
Hi thanks for your help but I still have a problem cause : the user will be provided by a combo box where he can choose a country from a list of countries. So Word files will be stored according to each country. For example if:

England is choosen from the combo box - there is a button that when clicked it opens the Word document related only to England.

Can someone please explain the process in steps..

Thanks a lot
 
link Access to word documents

Hi John,

can you please take a look at my form named : CountryInfo. where i set a combo box Country. Now when the user chooses for example England and wishes to view the related word document bY clicking on the button LINK TO WORD, it opens that document only (related to ENgland)

I think I must have a folder where it stores the related documents.:confused:

I tried with your code but i'm a bit confused..

thanks for your help
:o
 

Attachments

When your db open there is an error "Can't find macro etc".Plus you don't have any tables for the forms.

The code that you have behind the button "Link to Word" does not mean anything.

You have;

Code:
Dim stAppName As String

    stAppName = "C:\Documents and Settings\Vanessa\Desktop\Doc1.doc"
    Call Shell(stAppName, 1)

You should have;

Code:
Dim stAppName As String

    'You must have the "" "" (double quotes) around the path and document name"
    stAppName = "Winword.exe ""C:\Documents and Settings\Vanessa\Desktop\Doc1.doc"""
    Call Shell(stAppName, 1)


What I understand you want done, can be done (not with that code above).

Question:

Will all the "Country" documents be in the same path and folder? (e.g. H:\Documents\Countries\England.doc)

Do you want to have the path (e.g. H:\Documents\Countries) hard coded or would you like it in a table so that it can be changed. The code would use DLookUp to find it.

Let me know and I will see what I can do.
 
link Access to word documents

HI John,

I am resending the database with the tables and correct Forms.

Now I can manage all the documents (obviously having different names for example H:\Documents\CountryFiles\England.doc or H:\Documents\CountryFiles\Saudi.doc) under the same folder (with the same name for example path H:\Documents\CountryFiles)..

I don't think I will use different file paths (that is the need of a LookUp)

Thanks for your interest and help
 

Attachments

Have a look at the attached sample.

When the form opens, use the Country Lookup combo to locate Australia.
You will see how the major cities sub form works.
You can click the "Open Word Document" to try it, as you have no documents linked it will display a dialog box.

I have chosen to use the DLookUp as it make it easy for you to enter the path of your folder without having to change any code.

To use the program, put your douments in the folder, making sure that you have named the documents with the same name as in the country list in access. If you call the document United Kingdom it will not work as in the db you have UK.

When you have done this, open the program, close the form (frmCountry)
open the form frmFolderPath, enter you path, close it. Open the form frmCountry, and use the combo to find the country you want, click the command button "Open Word Document".

Hope this all works for you.
 

Attachments

link Access to word documents

Hi John, thanks for all your help, your example will definately help me a lot in my work.

THANKS ;)
 

Users who are viewing this thread

Back
Top Bottom