Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Import excel tabel whitin Word into Excel


Hi everybody. I'm stuck. I've this monthly report created in word tha
has a series of excel tables within. What I'm trying to do cretae
macro in excel that will open those copy the content and paste it i
a new Excel file.
How can be done??? I'm a newbie in the VB world and I thik this has t
do with OLEobjects.
THX,

Raven

--
Raven
-----------------------------------------------------------------------
Raven1's Profile: http://www.excelforum.com/member.php...fo&userid=1625
View this thread: http://www.excelforum.com/showthread.php?threadid=27654

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Import excel tabel whitin Word into Excel


even for non newbies this isn't exacly straightforward :)

Try following:
please be careful while testing as I've experienced some
crashes due to:
not closing the objects window before deleting the object...



Sub RetrieveEmbeddedXLS()

Dim wdDOC As Object
Dim wdOIL As Object
Dim wdEMB As Object
Dim xlEMB As OLEObject
Dim xlWKS As Worksheet
Dim xlwkb As Workbook

Dim r As Long, b As Long
Dim sDoc As String

sDoc = Application.GetOpenFilename("Word files, (*.doc)")
If sDoc = vbNullString Then Exit Sub

Set xlWKS = ThisWorkbook.Worksheets(1)
xlWKS.OLEObjects.Delete
r = 1
xlWKS.Activate
'First get them from word onto the activesheet...
Set wdDOC = GetObject(sDoc)
For Each wdOIL In wdDOC.inlineshapes
Set wdEMB = wdOIL.OLEFormat
If LCase$(wdEMB.progID) Like "excel.sheet*" Then
wdEMB.Parent.Range.Copy
xlWKS.Cells(r, 1).Activate
xlWKS.PasteSpecial _
Format:="Microsoft Excel Worksheet Object", _
Link:=False, DisplayAsIcon:=True

r = r + 6

End If
Next
Set wdEMB = Nothing
Set wdOIL = Nothing
wdDOC.Close (0)
Set wdDOC = Nothing

For Each xlEMB In ActiveSheet.OLEObjects
b = b + 1
xlEMB.Object.Windows(1).Visible = True
ActiveWorkbook.SaveAs "retrieved from " & _
Replace(Dir(sDoc), ".doc", "", compa=vbTextCompare) & b & ".xls"
xlEMB.Object.Windows(1).Visible = False
Next

xlWKS.OLEObjects.Delete


End Sub



HTH.. and good luck :)






--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Raven1 wrote :


Hi everybody. I'm stuck. I've this monthly report created in word that
has a series of excel tables within. What I'm trying to do cretae a
macro in excel that will open those copy the content and paste it in
a new Excel file.
How can be done??? I'm a newbie in the VB world and I thik this has to
do with OLEobjects.
THX,

Raven1

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import Word.doc into Excel CP Excel Discussion (Misc queries) 2 May 29th 09 08:39 PM
Import Excel in to word ETP Excel Discussion (Misc queries) 0 April 11th 08 03:16 PM
How do I Import Data From Excel to Word Angela Excel Discussion (Misc queries) 2 September 26th 07 11:10 AM
Hom do I import a word doc. into excel? Big Abalone Excel Discussion (Misc queries) 0 May 12th 06 06:01 PM
How do I import a WORD file into EXCEL? MauiMama Excel Discussion (Misc queries) 1 March 1st 05 03:36 AM


All times are GMT +1. The time now is 09:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"