?
Solved

Open word doc from the CURRENT directory in Access w/o full path

Posted on 2003-02-24
2
Medium Priority
?
249 Views
Last Modified: 2012-08-14
..without giving the full path name

H i,
 I need to keep a DB application portable so I do not want to hard code  the path name of the word documents that I open from a form.
Is there anyway to make it  look for the document in the directory of where ever the the DB is currrently installed?

currently i use this:

Dim WordApp As Word.Application
Dim WordDocument As Word.Document
Set WordApp = CreateObject("Word.Application")
WordApp.Documents.Open ("C:\temp\mydoc.doc")
WordApp.Visible = True

thx
0
Comment
Question by:kmittal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
HobsonT earned 80 total points
ID: 8013235
I use the following to return the path of the current database:
Public Function FilePath() As String
  Dim TempPath As String
  TempPath = CurrentDb.Name
  Do Until Right$(TempPath, 1) = "\"
    TempPath = Left$(TempPath, Len(TempPath) - 1)
  Loop
  FilePath = TempPath
End Function

To use this in your code:
Dim WordApp As Word.Application
Dim WordDocument As Word.Document
Set WordApp = CreateObject("Word.Application")
WordApp.Documents.Open (FilePath & "mydoc.doc")
WordApp.Visible = True

Hope this helps

Trevor
0
 

Author Comment

by:kmittal
ID: 8019289
Thanks a lot Trevor, exactly what I needed!
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question