save and retrieve a text file from a command button

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.
 
J

Jonathan Parminter

-----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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top