Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 3
Default Embedding Word Document within Excel

I would like to write a VBA procedure within Excel that
will allow me to embed/insert (not link) a Word document
(i.e. C:\My Documents\Test.doc) into the Excel worksheet.
The Excel worksheet would then allow me to click on the
embeded/inserted object for my perusal of the Test.doc
document. Any ideas?

If that's possible, is there a way for me to specify
several Word documents to embed/insert (i.e. wild
character searches, etc) into an Excel file and have all
of them embedded/inserted?

Any help in this matter would be greatly appreciated.

Sam

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Embedding Word Document within Excel

This might get you started:

Option Explicit
Sub testme03()

Application.ScreenUpdating = False

Dim myFiles() As String
Dim fCtr As Long
Dim iCtr As Long
Dim myFile As String
Dim myPath As String
Dim OLEObj As OLEObject

myPath = "c:\my documents\Word"
If Right(myPath, 1) < "\" Then
myPath = myPath & "\"
End If

myFile = Dir(myPath & "*.doc")
If myFile = "" Then
MsgBox "no files found"
Exit Sub
End If

'get the list of files
fCtr = 0
Do While myFile < ""
If LCase(myFile) Like "*asdf*.doc" Then
fCtr = fCtr + 1
ReDim Preserve myFiles(1 To fCtr)
myFiles(fCtr) = myFile
End If
myFile = Dir()
Loop

If fCtr 0 Then
For fCtr = LBound(myFiles) To UBound(myFiles)
Application.StatusBar _
= "Processing: " & myFiles(fCtr) & " at: " & Now
With Worksheets("sheet1")
Set OLEObj = .OLEObjects.Add(Filename:=myPath & myFiles(fCtr), _
Link:=False, DisplayAsIcon:=False)
OLEObj.Top = .Cells(fCtr, "A").Top
OLEObj.Height = .Cells(fCtr, "A").Height
OLEObj.Left = .Cells(fCtr, "A").Left
OLEObj.Width = .Cells(fCtr, "a").Width
End With
Next fCtr
End If

With Application
.ScreenUpdating = True
.StatusBar = False
End With

End Sub




Sam wrote:

I would like to write a VBA procedure within Excel that
will allow me to embed/insert (not link) a Word document
(i.e. C:\My Documents\Test.doc) into the Excel worksheet.
The Excel worksheet would then allow me to click on the
embeded/inserted object for my perusal of the Test.doc
document. Any ideas?

If that's possible, is there a way for me to specify
several Word documents to embed/insert (i.e. wild
character searches, etc) into an Excel file and have all
of them embedded/inserted?

Any help in this matter would be greatly appreciated.

Sam


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 3
Default Embedding Word Document within Excel

Thanks Dave . . . . I'll try it out and let you know if it
worked.

Sam


-----Original Message-----
This might get you started:

Option Explicit
Sub testme03()

Application.ScreenUpdating = False

Dim myFiles() As String
Dim fCtr As Long
Dim iCtr As Long
Dim myFile As String
Dim myPath As String
Dim OLEObj As OLEObject

myPath = "c:\my documents\Word"
If Right(myPath, 1) < "\" Then
myPath = myPath & "\"
End If

myFile = Dir(myPath & "*.doc")
If myFile = "" Then
MsgBox "no files found"
Exit Sub
End If

'get the list of files
fCtr = 0
Do While myFile < ""
If LCase(myFile) Like "*asdf*.doc" Then
fCtr = fCtr + 1
ReDim Preserve myFiles(1 To fCtr)
myFiles(fCtr) = myFile
End If
myFile = Dir()
Loop

If fCtr 0 Then
For fCtr = LBound(myFiles) To UBound(myFiles)
Application.StatusBar _
= "Processing: " & myFiles(fCtr) & "

at: " & Now
With Worksheets("sheet1")
Set OLEObj = .OLEObjects.Add

(Filename:=myPath & myFiles(fCtr), _
Link:=False,

DisplayAsIcon:=False)
OLEObj.Top = .Cells(fCtr, "A").Top
OLEObj.Height = .Cells(fCtr, "A").Height
OLEObj.Left = .Cells(fCtr, "A").Left
OLEObj.Width = .Cells(fCtr, "a").Width
End With
Next fCtr
End If

With Application
.ScreenUpdating = True
.StatusBar = False
End With

End Sub




Sam wrote:

I would like to write a VBA procedure within Excel that
will allow me to embed/insert (not link) a Word document
(i.e. C:\My Documents\Test.doc) into the Excel

worksheet.
The Excel worksheet would then allow me to click on the
embeded/inserted object for my perusal of the Test.doc
document. Any ideas?

If that's possible, is there a way for me to specify
several Word documents to embed/insert (i.e. wild
character searches, etc) into an Excel file and have all
of them embedded/inserted?

Any help in this matter would be greatly appreciated.

Sam


--

Dave Peterson

.

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
Embedding Excel Data into Word Ads[_2_] Excel Discussion (Misc queries) 0 May 4th 10 04:33 PM
embedding a Word Document into Excel JeanneL Excel Worksheet Functions 3 April 9th 08 08:44 PM
EMBEDDING WORD DOCUMENT IN SPREADSHEET Prasad Gopinath Excel Discussion (Misc queries) 1 February 11th 07 12:51 AM
Embedding or Linking (?) Excel in Word WinkinVan Excel Discussion (Misc queries) 0 October 23rd 06 06:19 PM
embedding a long word document r1mccann Excel Discussion (Misc queries) 1 November 10th 05 01:09 AM


All times are GMT +1. The time now is 07:18 PM.

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

About Us

"It's about Microsoft Excel"