Hello Stellan,
The code below is for the two seperate attachment options, image and file, which loads the objects on a different worksheet. So the next stage of the process is to export those attachments.
Many thanks
Jody
Hi, I have several workbooks being returned to me to validate, I built them so that an individual could attach both a word document and an image as separate objects added into the workbook with a macro. The macro identifies the name of the file and enters this name into cell A1.
Using this name, I now need to export that attached object to a folder called C:\ArchiveAttachments\
How can I do this, I can only think that I would a) need to use the name to identify which attached object to export, or b) use the name to identify the Object Number to export. Then I need to actually export it to the folder whether by opening it first or not. Any advice will be appreciated.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi Jody,
To get the embedded word document is quite straightforward. The document is opened in Word and saved, with the filename given from the cell where it was stored but with the path changed to your archive folder. The original filename cannot be retrieved from the embedded object but the progID property of the OLEobject is helpful in identifying what kind of file that was embedded.
However, the embedded image file is wrapped in a object package which does not expose the containing image file to VBA. To manually save the embedded image file you can right-click and select 'Package Object' -> 'Edit package' which will start the Microsoft Object Packager from where you can save the content as an image file. Sadly, the MS Object Packager cannot be controlled like MS Word. My best attempt is to use SendKeys after starting the Object Packager by sending the verb xlOpen to the OLEobject. SendKeys sends keystrokes to the active window as if typed at the keyboard.
Please try this code and tell me if you need more help or explanations. You have to set the reference to the MS Word Object library. In the VBE window select Tools->References..
Kind regards,
Stellan
Hello Stellan,
Fabulous!
I did get the debug error at line 13: Dim wordDoc As Word.Document
but by removing the 'As Word.Document' it works Ok
I also get an error on Line 41: SendKeys rngFileName.Value, True
This is the only place that I cant get passed, however the saving of the word Doc works perfectly!
Any idea what i might be doing wrong here? i am using excel 2007 and 2003 for these forms.
Many thanks
Jody
Hi Jody,
The first error, which you solved, was due to that you had not set the reference to the word object library. So the variable type Word.Document cannot be recognized. When you removed it, the wordDoc variable gets the type Variant. In this case that is fine. No need to change.
The second error is my fault. I had a test version first and then was careless when I put it all together. The line should be changed to:
SendKeys sArchivePath & sFileName, True
You should be aware of that SendKeys is not a very reliable method to control another application from Excel. It is actually like emulating that you are generating the keystrokes with the keyboard. Since the keystrokes are sent to the currently active window (which has to be the Object Packager in this case) you should not run the macro from the VBE.
Kind regards,
Stellan
Business Accounts
Answer for Membership
by: StellanRosengrenPosted on 2009-03-18 at 16:10:13ID: 23924824
Hi jodymichael,
Please show the code for the macro that inserts the objects.
Kind regards,
Stellan