Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Script Extract Embedded Files From Word

I have some Word 2003 docs that have many embedded Outlook 2003 .msg file objects, I want all those .msg files out and in a folder on my file system, if I try and click and drag them out I get a scrap error message, either way, I would rather do so with VBA for Office but I don't know how, there are many .msg files in the word doc (approx 50), will someone please let me know if this can be done with Office VBA

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Extract Embedded Files

I am new to VB.

I need a program which will scan through MS Office files (.doc, .xls, .ppt etc) and extract the embedded files from it.
This program shall run in batch mode without any user interaction.

Please refer the attachment. The blank.ppt file should be extracted from the word file and in the out put shall contain 2 separate files.
It should work recursively and do any level of extraction i.e if the file blank.ppt contains another fil, it should extract that too.

Please get back to me.

Thanks in advance

Using VBA To Extract Dates From Multiple Word Files To Rename Them?
Application: Word 2002
Code: VBA
Problem: I need the ability in VBA to extract the date multiple files were either created or last modified so i can then prefix the existing file with the date.

file.doc > 20070416-file.doc
file2.doc > 20070416-file2.doc
file3.doc > 20070411-file3.doc

I have found some code to read a directories list of files into a list box, and now i need the ability to be able to read the created / last modifed date in a similar way.

Here is the code to read the contents to a list box:

Dim MyFile As String
Dim Counter As Long

'Create a dynamic array variable, and then declare its initial size
Dim DirectoryListArray() As String
ReDim DirectoryListArray(1000)

Dim DirectoryListArray1() As String
ReDim DirectoryListArray1(1000)
'Loop through all the files in the directory by using Dir$ function
MyFile = Dir$("c: est*.*")
Do While MyFile <> ""
DirectoryListArray(Counter) = MyFile

MyFile = Dir$

Counter = Counter + 1

'Reset the size of the array without losing its values by using Redim Preserve
'ReDim Preserve DirectoryListArray(Counter - 1)

'To prove it worked you could run the following:

For Counter = 0 To UBound(DirectoryListArray)
'Debug.Print writes the results to the Immediate window (press Ctrl + G to view it)'
Debug.Print DirectoryListArray(Counter)
Next Counter

'To populate a Listbox from the array you could use:

ListBox1.List = DirectoryListArray

Any ideas?

Thanks in advance

Extract Embedded Excel File From EML?

I need to write a routine to read in an EML file an extract out of it the attached XLS file. The EML file contains the email header info and then the rest of the file contains the binary XLS file.

Does anyone know how to do this?


How To Extract Variables From Scripts Embedded In Html Pages
If anyone has an idea of how to extract variables from the web pageusing any method other then parsing the text tell me. Basically I needto access variables that are declared in javascripts in an html page anddon't know how to go about it. Can get the webpages through HTMLDocumentand can get the scripts with the element of HtmlScriptElement. Then Idon't know how to procede.

All help is appreciated.

Hardik Bati

Extract Each Word From A String And Print One Word Per Line.
I have a textbox that contains a string(can be any number of words).

How do i extract each word from the string and
print one word per line onto the form? e.g.

Hi can someone please help me

Print to form:


Embedded Word Documents And Word !?
I need to open an embedded word document (embedded in an access table) from vba access code , for editing in a word window ? can anyone help me with this ?

Embedded .Doc S And Word !
How do I open an embedded .doc file (embedded as a field in a table) in word for editing from code ?

Make All Files One And Extract To Original File Name Like In Zip Files
I have a listbox called a list1 which has a list of JPG,MP3,WAV and lots of other file types. I just want to save them all as a single file and extract them to their original file names.

Like what WINZIP does ............ but no need to compress them just want to make all those files into one big one.

i'm working on this program called game base ............. yeah ........ and u can see how it stores info.......... on differant dir ... and files.... want to make my prog save all files in a big bundle like a .FLA file in flash.


Embedded Word In Excel
Hi i have and embedded word document in excel sheet. When i use "open" verb
on embedded document in excel,it will open this document for editing in
microsoft word.
Is there any posibility to detect in word vba that this is embedded document
in excel sheet?

Tnx,Milos Vukov

Office 2k -> 2k3
Make word speak to you!

Embedded Word Document Can't Tab
In my VB App I embed a Microsoft Word form template (VbOLEPrimary), and then prefill some of the bookmarks with data from an SQL database. I then protect the document with wdAllowOnlyFormFields so that the user can only enter data into the remaining form fields. My problem is that the user cannot use the Tab key or the Backspace key. The forward Delete key works. Any ideas?

Also, when double clicking on the embedded Word Document the File Menu dropdown is absent and my users need to email their document easily. Is there an easy way to display the File menu or add the Email item?

Get Attachment Embedded In Word Doc

I try to get the attachment that is embedded in the MS Word document using Visual Basic 6.0. I have searched on google but did not find any info. Please help.


- Nikki -

Embedded Word Documents
I am trying to create a application that allows me to click on a command button which lets me read an OLE object from an Access database. I then want to be able to store the document onto the form, edit the document using Word (97) and write the document back into the database as an OLE object.

In concept the above seems simple but I am having all sorts of difficulties with it.

Can anyone point me in the right direction or offer some code to help. I have read the MSDN information until it is coming out of my ears but it has not helped.

Thankyou in anticipation

MS Word Embedded Objects
I am having all sorts of trouble using embedded MS Word OLE's in a Visual Basic application.
I am a novice with VB and what I am trying to do should be as simple as pie.
I want to click a button which will allow me to read an OLE field from an Access database and store it on a form. When I am happy with all the details on the form I want to update the database with the mdified OLE document.
Below is the code I have written but I obviously have the objects messed up as it does not work.

Any assistance would be greatly appreciated.


Option Explicit
Dim WB As Object
Dim Word As Object
Dim embeddedDoc As Document
Dim appWrd As Word.Application
Dim intChunkSize As Integer

Private Sub cmdOpen_Click()
'This routine is supposed to load up the OLE object on the form with the contents of the
' "Worddocument" field in the Access database
strTestword = "Select * from Testword where Control = 'Control'"
rsTestword.Open strTestword, dcnTest, adOpenStatic, adLockOptimistic, 0
intChunkSize = Len(rsTestword("Worddocument"))
OLE1.object.object = rsTestword("Worddocument").GetChunk(intChunkSize)

End Sub

Private Sub cmdSave_Click()
'This routine is supposed to save the OLE into the database into a field
'called Worddocument which is defined in Access as an OLE.

intChunkSize = Len(OLE1.DataField)
strTestword = "Select * from Testword where Control = 'Control'"
rsTestword.Open strTestword, dcnTest, adOpenStatic, adLockOptimistic, 0
rsTestword.Fields("Worddocument").AppendChunk OLE1.object.object

End Sub

Working In MS-word Embedded In VB
Dear All

I am developing an Data entry application using vb6.0.Users use to key by looking into the images.For images to view i am providing kodak image, for keying I am serious looking for having the ms-word document embed in vb6 since the keying requires all the stuff embedded in ms-word like paragraph,heading, subheading,etc.,

Is it possible?If so how to use it.please explain.



Interact With An Embedded Word Document With VBA
I have an Excel (2002) sheet with an embedded Word document (as an icon) that I want to interact with using VBA.
I have an User form containing a number of differnt fields represented by text- and Combo boxes linked to the Excel sheet. I also have a command button that is connected to the embedded Word document, making it possible to open it in Word.

When the user finish editing in the Word document I want to retreive some information from the document and place it in a cell in the Excel sheet and this is the point when my problem starts.

When I activate the Embedded Word document in the Command button_Click subroutine, the Word document is opened ok. But I don't know how to track when the user is ready with the document editing and has closed the document.
I can't track this in the Command button_Click subroutine after the activation because all code after the activation are run directly after the document is shown without waiting for the user to close the docuent.

I have tried to use the Word documents Document_Close() event but I never get to this subroutine when the document closes.

Any suggestions?

Creating Embedded Tables In Word With VBA?

I'm creating a Word document, from a template, to generate a series of labels. The formatting of the individual labels is somewhat complex, and seems to be handled best with a table. The label template is itself a table.

Procedurally, here's how it breaks down: I need to walk the cells of a table. Inside each cell I need to create a new table. I then need to walk the cells of that inner table, filling in data as I go, and then I need to step to the next cell in the outer table and repeat the process. I just can't figure out how to switch between the inner table and the outer table...

I'd really appreciate any insight anyone could offer. Thanks!

Macros In An Excel Doc. Embedded In A Word Doc.

I have a problem regarding macros in embedded documents.

I have an Excel worksheet that contains a macro. I also set a button to run that macro when it's cliqued.

When I insert the Excel worksheet into Word (97 by the way), with the options { link NO, icon YES }, my button doesn't work anymore...

I mean, when I open the document, I choose "Yes, activate the macros". Then Excel is run, and the workbook is named "Feuille de calcul dans C: WINNT Profiles XYZ Bureau Planning.doc" (yeah right, it's a french version ).

The button is still linked to the macro, but it won't do anything.
Still, when I open the VBA Editor, I can run the macro by clicking on the Run button.

Is there something with embedding that disables buttons ?
Weel, any idea is welcome, I'm completely stuck

Thank you


Viewing Embedded Word Documents
Ladies & Gentlemen

I am writing a project which consists of photographs of an airliner flight deck (I am a pilot by profession, very amateur VB programmer by hobby) Clicking on the various controls on the flight deck opens a new form with an OLE container that has an embedded word document in it with a description of the aircraft system. (It needs to be a word document because there is some quite complex text formatting and I need to be able to update the master document at regular intervals.)

Works fine on the PC that I am creating it on. Trouble is, when I package it up and put it on the laptop, only the very first OLE form that I click on has any text in it. When I open the next one, the OLE container is there with no text. However, if you double click on it then it opens for editing OK.

I am using the CreateEmbed method to state the Word documents to use and have tried oleUpdate, removing the embedded document and "re embedding" the next one etc etc but to no avail. Just to clarify, the user doesn't need to edit the text, just to view it in the OLE container.

Can anyone offer any assistance? Maybe I am trying to overcomplicate things here. Is there a more efficient way of showing a page of formatted text?

Any help much appreciated

Regards, Soup Dragon

Controlling An Embedded Excel In Word
For the life of me, I can't figure out how to determine the name of an Excel sheet which is embedded in my Word document. Without the name of the spreadsheet, I have no idea how to control it. This should be simple enough but I can't record a macro to provide me with some leads. I've attached the document to this message. Maybe someone can tell me how to control and insert some values in the spreadsheet from a separate VB app.

Thanks! Mike

Working With Embedded Excel In Word
Hello all.

I'm new here but hope to become an active participant.

Here is my first question:

We are working with embedded excel tables in word. (Office 2003) Specifically we have a macro which runs through and converts them over to word tables. While we are doing that, before it converts over, I would like to run a search and replace.

What is the syntax for doing this when we are working with Embedded Excel via a word macro?

Thanks all!

Can't Deactivate Ole Chart Embedded In Word

I can insert and manipulate an Excel Chart in word using the following code:

wd.Selection.InlineShapes.AddOLEObject ClassType:="Excel.Chart.8", FileName:= _
"", LinkToFile:=False, DisplayAsIcon:=False
numPlots = wd.ActiveDocument.InlineShapes.count
With wd.ActiveDocument.InlineShapes(numPlots).OLEFormat
Set objC = .object
End With

However, when I'm done doing stuff to the Excel Chart, I can't seem to write code to deactivate the ole object. It just stays activated (e.g. displayed as a workbook with a chart sheet and a worksheet). I can actually do stuff in Work programmatically while the Excel Chart is activated, but I wish to close/deactivate the chart so that the users sees only the ole chart.

Any help would be appreciated. Thanx!

Embedded Word, Menu Problem
Hello all-

I've embedded microsoft word 2000 into my VB form via the OLE Container Control.

My main form holds an activebar, menus, etc that cover the whole application. The form that I open up the OLE Container Control on is a sub form (ie it still has the activebar on the left, app-wide menus on the top).

When I embed the word application, the normal File, Edit, etc menus are shoved at the very top of the main form, instead of the subform. Why does this happen? I tried playing around with OLE Container Control in a totally separate blank project, and it appears that no matter where the OLE control is, the menus for embedded word are always at the very top of the form...

How can I move these menus to a desired location? It would be ideal of the whole embedded app was inside the OLE container, and didn't jump outside of it....

Thanks for the help!!


Using An OLE Embedded Ms Word And Writing From It To A File
Thanks Sherwood, for the code, but it seems the code does not work.

It keeps giving me the error :

"Active X component cannot create object"

PLease i need ur help again.


VB OLE With Embedded Word - Freezing The OLE Container
I have a VB application that hosts a Word document.

1) I want the OLE Container outline to never resize itself.
So, I set the SizeMode property to 3 - Zoom. Documentation states that this setting forces the embedded object to conform to the OLE Container. When the SizeMode is set to 3 the document is loaded into the OLE Container, but it does not fill the OLE Container.

Note: I set the SizeMode property to 0 - Clip. This setting works much better, however when I modify the PageMargins the OLE Container increases in size.

Any thoughts...

Excel Worksheet Embedded In Word
I use the following code to create an Excel worksheet embedded in my Word
Code:Dim shp as Shape
    Set shp = ActiveDocument.Shapes.AddOLEObject(Anchor:=Selection.Range,ClassType _
    := "Excel.Sheet.8", FileName:="", LinkToFile:=False,DisplayAsIcon:=False)

Using more code, I can manipulate the contents of this worksheet.

BUT, I cannot work out how to control the size of the worksheet so that I
can see more of it. All properties that refer to height or width simply
enlarge the visible contents so that I see the same amount of the worksheet
but it's bigger.

How can I enlarge the rectangle that contains the embedded object, keeping
the contents the same size so that more of the contents are visible?

This is easy with the mouse - simply drag the borders when the object is
active but I cannot work out how to do this programmatically.

I've tried to turn on macro recording, resize the
rectangle, then turn off recording. What I have recorded is an empty Sub!!
I have tried various ways to record the actions but with no success

Please help me!!!!!!!!!!!!!

Edited by - Adagar on 4/16/2003 12:29:18 PM

Linked &amp; Embedded Objects In Word VBA
From my udnerstanding, The M$ Word object model exposes two types objects that assist in OLE linking and embedding: inlineshape and shape.

What I'd like to do it to display either an inlineshape or a shape (determined at runtime) on a Word VBA Form in such a manner that I do not have to worry about what the Type property of the shape/inline shape is or if the object is a inlineshape vs a shape. Does anyone have any ideas?


Read PDF Files / Extract Data From PDF Files
I wondering IF it's possible to read data from pdf files?

This because I would like to write a sub for pdf files like below:


Text = ReadWordDocument("C:TempTest.doc")

Public Function ReadWordDocument(strFileName As String) As String

Set oWordApp = CreateObject("Word.Application")
If oWordApp Is Nothing Then Exit Function

Set oWordDoc = oWordApp.Documents.Open(strFileName)

ReadWordDocument = oWordApp.Selection.Text


Set oWordDoc = Nothing
Set oWordApp = Nothing

End Function

Embedded Wav Files
i've embedded a wav file on my form through OLE. how do i play that sound file? i don't mean to open it...just to play it in background.....

Need Help! How To Create A Word Object Embedded In A Form?
Hi there! I know how to create a word object, my project opens Microsoft Word and pastes there, but how could I make it an embedded word object? And something else... When I paste using .selection, my whole page is selected. How do I remove (not delete) the selection?
Thanks in advance!

Open/Edit Embedded Worksheet In WORD
I have been trying desperately to get a macro in word (and thus hopefully my VB app.) to simply find the embedded Excel sheet within a word document.
That was the easy part, the thing I am now believing may in fact be impossible, is getting it to then open the embedded worksheet (in MS Word) and 'Select-All' then 'Paste' it into an existing worksheet wihthin Excel.
By recording a new Macro, I try and do this (having it track the changes I make and thus writing a script for me), but ONLY when the macro is recording, the program will NOT allow me to either double-click the spreadsheet OR right click it (so I could then choose 'Edit' or 'Open').
I hope this function is not completely impossible, either through Word or VB, so If any of you experts out there know anyhting about this, your help would be GREATLY appreciated! thanks...

How To Extracte Embedded File Object In Word.
Hi! HOw Can I extract and Save embedded file in Microsoft Word using Visual Basic.

For exmaple I have a Word File and I insert an Object File as an Icon...
If we open the Word File and I click the Icon.. I will be able to save this file right? This is What I want to do in Visual Basic.



Embedded Data From Database To Word Document
I want to embedded query result to existing word document, for example:

'I have a document that contain this text
hi my name is :

'then I want embedded the name to it from my db...

pls advice..

Accessing Embedded Text File In MS Word

I am accessing a MS Word document programmatically in VB and attempting to save all embedded objects as files.

The embedded objects are all text files.

I am using ActiveDocument.InlineShapes(1) to access the first embedded object, but the object type (Prog ID) is reported as 'Package'.

I assume that this is because the Object Packager is being used internally to package the text file and embed it to word.

But I cant seem to manipulate the Package object (I cant even set a reference to it!).

If I manually open the embedded object in Object Packager I can save the text file.

I want to do the same thing through code. Can someone help me on how to do this?


Extract A Word From A Web Page...
How would I go about getting a single word from a web page? Lets say I go to and want to get the amount for icoins (points) that the user currently has and display it in a text would I do that?

Extract Data From Word
Hi Guys,
I'm getting stuck on a little problem here:
I want to extract variable length data from a Word doc, I want to be able to create a string of all of the text starting below the greeting line in a letter of "Dear So & So" and finishing at the end of the line above "Yours sincerely" so I can do things with it in VB.
I'm a newbie to VBA, I've searched various forums but can't find an answer anywhere.
I can do the find for the start and finish of the document area concerned, but I don't know how to tell VBA where these start/finish points are, and how to copy a selection into a variable, or some format that I can then parse etc in VB.
Any help would be much appreciated.

HOW To Extract Word From A Sentence?
For example:
if user type "I love icecream"
how do i extract each word and put "I", "love", "icecream" into 3 different variables?
a="I" B="love" C="icecream"

Extract Bookmarks Value From Word.doc
Anybody please help me out how to extract bookmarks values from a word doc?

I have a word document with many bookmarks field named from Text1, Text2, Text3....etc.

What I did was:

Dim w As Word.Document
Dim a As Word.Application
Dim output1 As String

Set a = New Word.Application
Set w = New Word.Document
Set w = a.Documents.Open("c:my document est303.doc")

output1 = w.Bookmarks.Item(1) -> This only retreive BookMarks name as "Text1" The "Text1" current contains value "ABC Company". How to extract value from "Text1"?


To Extract The First Word From A Text Box
I need to extract the first word from data in a text box (up to the first space) to use in an sql statement. What is the best way to do this?

To Extract The First Word From A Text Box
I need to extract the first word from data in a text box (up to the first space) to use in an sql statement. What is the best way to do this?

Extract MS Word Information

I have several (well, several hundred) word documents. I need to extract information from each such as Author, Date Created etc... how would I go about doing this for a single document?


Extract Data To Word
Hi there,
does anyone know of a compent that will allow me to place data I have in a Word document and save it from jmy vb application

Cheers in advance

Update Shown Cells In Embedded Worksheet In Word
I have a Word document with an embedded Excel worksheet. I have certain macros in the worksheet (run by the user) that insert or delete rows. When this happens the embedded object is not automatically updated with the cells that should be shown. I know this can be done by dragging the borders of the object, but is there any way to do this programmatically? I've been at this most of the day. I can't find any propery or method of InlineShape that will do this.

The best I've come up with is to select the new correct cell range in the embedded worksheet, and paste it in Word as a new embedded worksheet, and then delete the old one. When you paste, the "selection size" is automatically correct. This isn't an ideal solution. For one thing the Excel document closes, since it's deleted, and the user has to right click|[Worksheet object]|[Open] again (on the new object).

Here's what I do now:

Dim xlwb As Excel.Workbook
Dim oCurrentList As Object

Set oCurrentList = ActiveDocument.InlineShapes(1)
Set xlwb = oCurrentList.OLEFormat.Object

Selection.PasteSpecial Placement:=wdInLine, DataType:=wdPasteOLEObject
By the way, I'd also like to know how to do this programmatically, right click|[Worksheet object]|[Open] -- so that the worksheet opens as a new window in Excel. [InlineShapes(x).OLEFormat.Open] doesn't do this. Seems [.OLEFormat.Open] and [.OLEFormat.Activate] and [.Activate] do the same thing...

Thank you for any help,

Enable/disable Embedded Buttons In A Word Document

I have some embedded buttons in a word document and I want to programatically enable/disable some of them. I can access the buttons objects with the InlineShapes property of the document, and check they really are buttons (Type = 5), but when I try to use the Enabled property VB says me that object has no "Enabled" property.

Anyone knows how to do it?

Thank you in advance!

Copy&amp;Paste From Excel To An Embedded Word Doc Page 2
Im Having 2 problems.
1) How do u open the existing document without wiping out previous changes(like the bookmarks I added). The following code seems to create a new word doc instead of using the existing document embedded.

2) How would I Paste spreadsheet range onto Page2? Bookmarks?

The following code is what I have come up with so far:

Excel.ActiveWorkbook.Worksheets(1).Shapes("OBJECT 1").Select
Selection.Verb Verb:=xlPrimary

instead of the first two lines of code

**RESOLVED**Crystal Reports / Embedded Word Document
Is there any way to place an embedded Word document within a Crystal Rpt? If so, how?

Hiding Excel When Processing Spreadsheet Embedded In Word
I’ve written a program which converts Excel spreadsheets embedded in Word into Word tables. I don’t want either Word or Excel to be visible. Hiding Word is straightforward:

Set wdApp = New Word.Application
wdApp.Visible = False

but I can’t figure out how to totally hide Excel. I’m opening the embedded object with the following code, which does hide Excel but only after it has appeared on screen for a split second:

Code:For Each myInlineShape In wdApp.ActiveDocument.InlineShapes
 If InStr(1, LCase(myInlineShape.OLEFormat.ProgId), "excel.sheet") > 0 Then
   Set myExcelSheet = myInlineShape.OLEFormat.object
   myExcelSheet.Application.Visible = False

myInlineShape.OLEFormat.DoVerb (wdOLEVerbHide) has no effect.
I thought of maybe opening Excel in the same way as Word and then somehow assigning myInlineShape.OLEFormat.object as the active workbook but I can't figure out how.

How To Get OLE Embedded Files To Save
I am trying to makeit so that a person could save imbedded objects in my exe to a directery. Does anyone have any Idea's?

Embedded AVI Files As Resources

I am trying to find out how to add compiled avi files to a vb application. At present I am using the Resource compiler for bitmaps and icons but dont seem to be able to add avi's. Also the avi control accepts file strings and not resource ID's.

Does anyone have any experience in this


Iterating Through Word Doc W/ Tables,pics, Embedded/linked Objects
Hello All,

I was wondering if anyone could help me with a problem I'm having in VBA Word2000:

I need to iterate through a word document a process each item as it appears in the documents. As I understand it, the items I might be looking for include paragraphs, tables, pics, embedded/linked objects. Does anyone know where I could find a complete list and more importantly, how I can iterate across ALL of them as the appear in the document?

I already see that there are a bunch of collections in place inside a document. Will I have to determine the order of all theobjects in all the collections manually?

I have in front of me Wrox's Word 2k VBA book but I'm trying to get some more detailed reference information ... if you know of some pls lemme know.

Copyright 2005-08, All rights reserved