G
Guest
I have a routine that opens an existing Word Doc, pastes (special) a metafile
picture from Excel, and attempts to modify the properties of the picture.
After the paste the picture is sized at 89%. The code is actually selecting
the pasted picture, but none of the methods have any effect on the size and
orientation of the picture. My goal is to size the picture to 100% and
center it in the Word doc. (Interestingly, when I paste an Enhanced
metafile, the picture is sized at 100%, but the result is a huge file.) The
code being executed from Excel, which follows, does work when executed from
Word!
Here is the guts of the code:
WordApp.Visible = True
On Error Resume Next
With WordApp.Selection
.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafilePicture, _
Placement:=1, DisplayAsIcon:=False
End With
ActiveDocument.Shapes.SelectAll
With Selection.ShapeRange
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
Selection.ShapeRange.Height = 606.25
Selection.ShapeRange.Width = 483.85
Selection.ShapeRange.Left = wdShapeCenter
End With
ActiveDocument.SaveAs Filename:=SaveDocName,
FileFormat:=wdFormatDocument, _
LockComments:=False, Password:="", AddToRecentFiles:=True,
WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _
False
picture from Excel, and attempts to modify the properties of the picture.
After the paste the picture is sized at 89%. The code is actually selecting
the pasted picture, but none of the methods have any effect on the size and
orientation of the picture. My goal is to size the picture to 100% and
center it in the Word doc. (Interestingly, when I paste an Enhanced
metafile, the picture is sized at 100%, but the result is a huge file.) The
code being executed from Excel, which follows, does work when executed from
Word!
Here is the guts of the code:
WordApp.Visible = True
On Error Resume Next
With WordApp.Selection
.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafilePicture, _
Placement:=1, DisplayAsIcon:=False
End With
ActiveDocument.Shapes.SelectAll
With Selection.ShapeRange
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
Selection.ShapeRange.Height = 606.25
Selection.ShapeRange.Width = 483.85
Selection.ShapeRange.Left = wdShapeCenter
End With
ActiveDocument.SaveAs Filename:=SaveDocName,
FileFormat:=wdFormatDocument, _
LockComments:=False, Password:="", AddToRecentFiles:=True,
WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _
False