PDA

View Full Version : How to Select a "mso Embedded OLE Object" ?



zemelo
12-30-2010, 09:34 AM
I have a document with a "mso Embedded OLE Object" on the first page.

When I just open this document and do not select anything and select a Shape with a macro it tells me that it is of the type 1.

Only when I click in the document and select the object before I run the macro it tells me that a type 7 Shape is selected

My question :
How can I select a type 7 Shape with a macro (to be able, to modify its contrast)

Anton

fumei
12-31-2010, 10:39 AM
Not quite following. Perhaps post your code. Are you using a Shape object?
Dim oShape As Shape
Set oShape = ActiveDocument.Shapes(1)

zemelo
01-01-2011, 12:42 AM
Hallo Gerry,

Thank you for your response.

This is the code for telling me which kind of shapes are in the document:

Sub CountShapes()
Set doc = ActiveDocument
MsgBox "InlineShape = " & doc.InlineShapes.Count & vbCr & "Shapes = " & doc.Shapes.Count
End Sub

The document I have contains an InlineShape. However the above macro only reports a Shape.
Only when I click in the document with the mouse before I run the macro a picture is selected and the macro reports an InlineShape correctly.

My real problem is: I have not been able to write a macro which selects the picture (simulates a mouse click).

My code for converting the shape into an InlineShape did not produce the desired result:

Sub ConvertToInlineShape()
ActiveDocument.Shapes.SelectAll
MsgBox "InlineShape = " & ActiveDocument.InlineShapes.Count & vbCr & "Shapes = " & ActiveDocument.Shapes.Count
With Selection
If .Type = wdSelectionShape Then
.ShapeRange(1).ConvertToInlineShape
End If
ActiveDocument.Shapes.SelectAll
MsgBox "InlineShape = " & ActiveDocument.InlineShapes.Count & vbCr & "Shapes = " & ActiveDocument.Shapes.Count
End With
End Sub

It would be very helpfull for me if I could send you the word-document which I use for testing the macro.

Anton

Paul_Hossler
01-01-2011, 09:17 AM
It seems .ConvertToInlineShape is a function that returns a Shape object so at least this bit of code seems to select the shape


Sub drv()
Dim oShape As Shape
With Selection
If .Type = wdSelectionInlineShape Then
If .InlineShapes(1).Type = wdInlineShapePicture Then
.InlineShapes(1).Select
ElseIf .InlineShapes(1).Type = wdInlineShapeEmbeddedOLEObject Then
Set oShape = .InlineShapes(1).ConvertToShape
oShape.Select
End If
End If
End With
End Sub


Paul

zemelo
01-02-2011, 01:54 AM
Thank you very much, I still have problems.
Maybe I was not very clear in describing my problem.

I have a Word-document with a picture. I want to increase the contrast of this picture. To do this I can click with the mouse into the first page, then Word 2007 allows me to change the contrast in the PictureTools

Now my problem is that I cannot record a macro and start with the mouse click and then go to the picture-menu to call up the contrast change.

Therefore I have to write the macro. But I cannot find a way to "simulate" the mouse click.

I try now to attach my word document.

zemelo
01-06-2011, 04:11 AM
To all how helped me sofar :

I had hoped to get some more help relative to the attachement ShapeTest.docx I posted on 1-02-2011.

I would very much appreciate if somebody could tell me how to write a macro to increase the contrast of the document.

Thank you
Anton