save and retrieve a text file from a command button

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

Guest

I would like to open for editing a text or MSWord file based upon the
employee number and last name. I want to be able to push a command button
and Access look for a file and open it. If there is no such file, create
one and open it. Any suggestions.
 
-----Original Message-----
I would like to open for editing a text or MSWord file based upon the
employee number and last name. I want to be able to push a command button
and Access look for a file and open it. If there is no such file, create
one and open it. Any suggestions.
.
Hi David,

use the following as an example:

In declarations section of module (top)
private mWordApp as Object
private mWordDoc as object

sub OpenFile(DocPathAndName as string)

If GetWord() then
on error resume next
set mWordDoc=mWordApp.Documents.open DocPathAndName

if err<>0 then
' error (maybe) document does not exist
set mWordDoc=mWordApp.Documents.add
end if
end if

private function GetWord() as boolean
if mWordApp is nothing then
' reference ms word
on error resume next
set mWordApp=getobject(,"winword.application")

if err<>0 then
' ms word not already open
set mWordApp=New winword.application
end if
end if

getword=true
end if

Luck
Jonathan
 
Back
Top