I have a 1000 page document in a MS Publisher..
I have to resize every TextFrame. There are approximately four per page.
My Macro looks like this:
Sub Resize_Textbox()
Dim pubPage As Page
Dim pubShape As Shape
For Each pubPage In ActiveDocument.Pages
For Each pubShape In pubPage.Shapes
If pubShape.Type = pbTextFrame Then
pubShape.TextFrame.Height = "21.5 cm"
If pubShape.TextFrame.Width = "18 cm" Then
pubShape.TextFrame.Width = "12.6 cm"
End If
If pubShape.TextFrame.Width = "8.75 cm" Then
pubShape.TextFrame.Width = "6.3 cm"
End If
End If
Next pubShape
Next pubPage
End Sub
I checked Macro Security and have enabled all Macros. I saved everything.
It gives me an error in line where I want to change the height of the textframe.
In VBA, the height and width properties are done in points not literal cm, you can use
CentimetersToPointsto convert it to the required value.Do not include the " cm" suffix.
EDIT\ADDITIONAL:
I run a test and did not get the error your getting, the difference being that I was working with declared variables. Your error message would usually imply we need
set =before it or that we are referencing something that isn't there.Try the below in your method and see if it works (Note this sample only does page one): -