Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Print out embedded Word object

I have embedded a word document in a excel sheet and now want to
figure out how to print the word document using VBA. I found the
following in one of the groups and it seems to error out at Set wDoc =
wObject.Object
"Type mismatch"

I think that I have all the references set correctly.

I would appreciated any help you might be able to provide.

Sub OpenPrintCloseWordDoc()
Dim wksDocs As Worksheet
Dim wObject As OLEObject
Dim wDoc As Word.Document

Set wksDocs = ThisWorkbook.Worksheets("Well Summary")
For Each wObject In wksDocs.OLEObjects
wObject.Activate
Set wDoc = wObject.Object
wDoc.PrintOut
wDoc.Close
Next wObject
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Print out embedded Word object

After some further searching I also found this. I get an error at
ActiveSheet.OLEObjects(i).Object.Application.Print Out when I use it in
the workbook I am developing.

When I copy this code to a newly created blank workbook and embed a
word file - it works fine. Does anyone have any ideas why it would
work correctly in one instance and not the other?


Sub otherprint()
For i = 1 To ActiveSheet.OLEObjects.Count
ActiveSheet.OLEObjects(i).Activate
ActiveSheet.OLEObjects(i).Object.Application.Print Out
ActiveSheet.OLEObjects(i).Object.Close
Next i
End Sub



On Apr 28, 1:16*pm, wrote:
I have embedded a word document in a excel sheet and now want to
figure out how to print the word document using VBA. I found the
following in one of the groups and it seems to error out at Set wDoc =
wObject.Object
"Type mismatch"

I think that I have all the references set correctly.

I would appreciated any help you might be able to provide.

Sub OpenPrintCloseWordDoc()
Dim wksDocs As Worksheet
Dim wObject As OLEObject
Dim wDoc As Word.Document

Set wksDocs = ThisWorkbook.Worksheets("Well Summary")
For Each wObject In wksDocs.OLEObjects
wObject.Activate
Set wDoc = wObject.Object
wDoc.PrintOut
wDoc.Close
Next wObject
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Print out embedded Word object

Okay solved the problem - I also had an ole button on the sheet and
the code was trying to act on it as well and was creating the error.

On Apr 28, 3:19*pm, wrote:
After some further searching I also found this. I get an error at
ActiveSheet.OLEObjects(i).Object.Application.Print Out when I use it in
the workbook I am developing.

When I copy this code to a newly created blank workbook and embed a
word file - it works fine. Does anyone have any ideas why it would
work correctly in one instance and not the other?

Sub otherprint()
For i = 1 To ActiveSheet.OLEObjects.Count
* *ActiveSheet.OLEObjects(i).Activate
* *ActiveSheet.OLEObjects(i).Object.Application.Prin tOut
* *ActiveSheet.OLEObjects(i).Object.Close
Next i
End Sub

On Apr 28, 1:16*pm, wrote:



I have embedded a word document in a excel sheet and now want to
figure out how to print the word document using VBA. I found the
following in one of the groups and it seems to error out at Set wDoc =
wObject.Object
"Type mismatch"


I think that I have all the references set correctly.


I would appreciated any help you might be able to provide.


Sub OpenPrintCloseWordDoc()
Dim wksDocs As Worksheet
Dim wObject As OLEObject
Dim wDoc As Word.Document


Set wksDocs = ThisWorkbook.Worksheets("Well Summary")
For Each wObject In wksDocs.OLEObjects
wObject.Activate
Set wDoc = wObject.Object
wDoc.PrintOut
wDoc.Close
Next wObject
End Sub- Hide quoted text -


- Show quoted text -


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
Need text from embedded Word object c mateland[_2_] Excel Programming 2 June 3rd 08 12:10 AM
Embedded word object GS80 Excel Programming 0 February 22nd 08 09:31 AM
Printing an embedded Word Object bluegrassstateworker Excel Programming 0 May 4th 07 02:58 PM
Extracting text from embedded Word Object Barb Reinhardt Excel Programming 1 September 25th 06 10:49 PM
Reference to an Embedded Word Object [email protected] Excel Programming 2 April 20th 06 03:05 PM


All times are GMT +1. The time now is 05:32 AM.

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"