View Single Post
Join Date: Mar 2006
Posts: 191
Reputation: HI2Japan is an unknown quantity at this point 
Solved Threads: 20
HI2Japan HI2Japan is offline Offline
Junior Poster

Help with code modification

 
0
  #1
Nov 20th, 2008
I'll start off saying I am not a programmer. I am making a database that imports data from Word forms. It requires code and I found some that works almost perfectly for me at http://msdn.microsoft.com/en-us/libr...ffice.10).aspx
It does exactly what I need. The only thing that would make this code better would be to use relative references to the database and imported files.

strDocName = "C:\Contracts\" & _
	InputBox("Enter the name of the Word contract " & _
	"you want to import:", "Import Contract")

Set appWord = GetObject(, "Word.Application")
Set doc = appWord.Documents.Open(strDocName)

cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
	"Data Source=C:\My Documents\" & _
	"Healthcare Contracts.mdb;"
rst.Open "tblContracts", cnn, _
	adOpenKeyset, adLockOptimistic

In a previous database, I was able to use CurrentProject.Path to allow for relative paths, but I can't figure out how to get that to work with this code.

Can anyone please help me by letting me know how to set up a relative path for the referencing. I am planning on storing the database and files to be imported in the same folder.

Thank you
Who was the first person to look at a cow and say, "I think I'll squeeze these dangly things here, and drink whatever comes out!"
Reply With Quote