Open attachment w/ VBA in Access 2007?

P

Patti

Is there a way to progam a button to open an attachment in Access
2007?
I'm trying to get around using the built in method of double clicking
the
attachment and choosing Open.

Many thanks!
 
P

Piet Linden

Is there a way to progam a button to open an attachment in Access
2007?
 I'm trying to get around using the built in method of double clicking
the
attachment and choosing Open.

Many thanks!

what if you use Application.FollowHyperlink?
 
P

Patti

what if you use Application.FollowHyperlink?

That would assume that the file in the Attachment field is a valid
hyperlink address, which I don't think it is. What I am really
looking for is a way to open the Word file, let the user make some
edits, then close Word and save the changes to the Word file in the
Attachment field. I would really rather not do the SaveToFile then
LoadFromFile methods. That just seems like a whole bunch of coding
that really shouldn't be necessary. And in fact, I am really not sure
that what I am trying to do is possible with SaveToFile then
LoadFromFile because how would Access know that the user was done
editing the file? What event would that be? If we are shelled out to
Word, then there is no Access event to capture.

Any other thoughts?

Again, many thanks!

Patti
 
C

Carl Rapson

FollowHyperlink doesn't just work for web addresses. It will use whatever
application is defined under File Types (in Explorer) to open the file you
give it - if it's an .XLS file it will use Excel, if it is a .DOC file it
will use Word, etc.

Carl Rapson
 
P

PattiB

Thanks for your reply.

How do I get to the attachment? Here is the code that I have tried:

Private Sub cmdViewProp_Click()
Dim strFile As String
Dim rst As DAO.Recordset2
Dim rsa As DAO.Recordset2
Dim fld As DAO.Field2

Set rst = Me.RecordsetClone
Set fld = rst("PropDoc")
Set rsa = fld.Value
'MsgBox (rsa("filename"))
Application.FollowHyperlink rsa("FileData")
End Sub

This gives me the error message: Run-time error '490' Cannot open the
specified file.

I realize that I need to navigate through the attachments and find the one I
am looking for, but right now I will be happy just opening *anything*! LOL
For this particular record, my msgbox indicates that I am on a record with
the filename "Proposal Test.docx," which is the one that I want for now. :)

Many thanks!

Patti
 

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