Opening a word file with Access 2000 - Help with API

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All

I am new to VBA and need some very basic help. I have read from previous
posts that the best way for a file to be opened for use in an Access 2000
application is to use the API located at

http://www.mvps.org/access/api/api0001.htm

How do I actually implement this, where do I put this API, and how do I
reference this from my code?

My code currently has a hard coded file name, but I want the user to be
able to choose a file each time the code runs.

Any assistance would be great.

Thanks

Dan
 
Create a new module (go to the Modules tab and click on New). Copy
everything between Code Start and Code End, and paste it into the new module
you just created. Save the module (give it a name like mdlFileDialog to make
sure that it isn't the same name as any of the routines in the module)

Go back into that module and add the following function:

Function GetWordFile() As String

Dim strFilter As String

strFilter = ahtAddFilterItem(strFilter, "Word Files (*.Doc)", "*.Doc")
GetWordFile = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
End Function

Any time you want the user to be able to select a word file, simply call the
function GetWordFile, and it will return the full path to the file they
selected.
 
Back
Top