Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-16-2011, 06:20 AM
DugganSC DugganSC is offline Editing an embedded OLE object Windows XP Editing an embedded OLE object Office 2007
Novice
Editing an embedded OLE object
 
Join Date: Aug 2011
Posts: 8
DugganSC is on a distinguished road
Smile Editing an embedded OLE object

I've been assigned to design some Word macros to clean up exported requirements documents from Telelogic DOORS. Among other tasks, the current cover page is being exported as an embedded Word document. I need to do two things with it. First, I need to center the embedded object on the page (currently, it's aligned with the left side in the center of the document). Second, I need to go into the embedded object and find a piece of text. I can do the latter once I've opened the OLE object, but I haven't figured out how to do that programmatically yet. My usual method for figuring out how to do things in Word macros is to record a macro and then look at the code, but double-clicking into an object seems to be disabled when recording the macro.

I found an example of opening embedded objects at http://thedailyreviewer.com/windowsa...g-vba-10672616 but that only seems to find the images in my document.

Any help?
Reply With Quote
  #2  
Old 08-29-2011, 01:40 PM
DugganSC DugganSC is offline Editing an embedded OLE object Windows XP Editing an embedded OLE object Office 2007
Novice
Editing an embedded OLE object
 
Join Date: Aug 2011
Posts: 8
DugganSC is on a distinguished road
Thumbs up

Ah, figured it out. The object was embedded as a Shape. I discovered this by first realizing that there was a Context Menu item to open the embedded document whereupon I recorded a macro to access it. For the sake of reference, the macro code I got for finding it, opening it, finding a piece of text, copying what followed it, closing the document, and pasting said text into the header is the following:
Code:
If ActiveDocument.Shapes.Count > 0 Then
        ActiveDocument.Shapes(1).Select
        Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
        
        With Selection.ParagraphFormat
            .LeftIndent = InchesToPoints(0#)
            .FirstLineIndent = InchesToPoints(0#)
        End With
        
        Selection.ShapeRange(1).OLEFormat.DoVerb VerbIndex:=1
    
        Selection.Find.ClearFormatting
        With Selection.Find
            .Text = "Document ID"
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute
        Selection.MoveDown Unit:=wdLine, Count:=1
        Selection.HomeKey Unit:=wdLine
        Selection.EndKey Unit:=wdLine, Extend:=wdExtend
        Selection.Copy
        Selection.EscapeKey
        ActiveDocument.Close
        WordBasic.ViewFooterOnly
        Selection.TypeText Text:="Document "
        ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    Else
        MsgBox ("Failed to find cover page")
    End If

Last edited by DugganSC; 08-29-2011 at 01:42 PM. Reason: Fixing a zero-index issue
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Editing an embedded OLE object Embedded File Atlas Word 1 06-20-2011 04:37 PM
Editing an embedded OLE object Embedded links spheon Word 1 06-07-2011 04:11 PM
Embedded in invitation? admin99 Outlook 0 08-28-2010 05:34 PM
Problem: object library invalid or contains references to object definitions aligahk06 Office 0 08-19-2010 12:29 PM
Could not load this object as this object is not present in your computer k.gaurav Office 0 08-17-2009 09:57 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:05 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft