U
ucanalways
I am trying to write a macro that will find all excel charts and
pictures in a word document and resize it uniformly (equal size and
aligned in the center of the document.
To test, I have one excel chart and a picture in page1. Command button
is also in page1.
Iused F8 to check what's happening in my code and I found that the
variable shp takes the value "Nothing". So, the for loop is not being
executed. Any idea what am I doing wrong? Please let me know.
Currently, I have the following code. Please note that the following
subroutine is in MS WORD and not in excel.
Sub test()
Dim shp As Shape
Dim wsactive As Document
Set wsactive = ActiveDocument
For Each shp In wsactive.Shapes
If shp.Type = msoChart Then
shp.ScaleWidth 1.6, msoFalse, msoScaleFromTopLeft
shp.ScaleHeight 1.46, msoFalse, msoScaleFromTopLeft
End If
If shp.Type = msoDiagram Then
shp.ScaleWidth 1.6, msoFalse, msoScaleFromTopLeft
shp.ScaleHeight 1.46, msoFalse, msoScaleFromTopLeft
End If
Next shp
End Sub
pictures in a word document and resize it uniformly (equal size and
aligned in the center of the document.
To test, I have one excel chart and a picture in page1. Command button
is also in page1.
Iused F8 to check what's happening in my code and I found that the
variable shp takes the value "Nothing". So, the for loop is not being
executed. Any idea what am I doing wrong? Please let me know.
Currently, I have the following code. Please note that the following
subroutine is in MS WORD and not in excel.
Sub test()
Dim shp As Shape
Dim wsactive As Document
Set wsactive = ActiveDocument
For Each shp In wsactive.Shapes
If shp.Type = msoChart Then
shp.ScaleWidth 1.6, msoFalse, msoScaleFromTopLeft
shp.ScaleHeight 1.46, msoFalse, msoScaleFromTopLeft
End If
If shp.Type = msoDiagram Then
shp.ScaleWidth 1.6, msoFalse, msoScaleFromTopLeft
shp.ScaleHeight 1.46, msoFalse, msoScaleFromTopLeft
End If
Next shp
End Sub