Sizing a Form Control

G

Greg Maxey

I have a control toolbox command button in a protected form. When inserted
the height property is 24 and the width property is 72. The control is
formatted as a floating shape.

When I run the following code the control is not visible in the form:

Sub HideResetCommand()
Dim oCtr
Set oCtr = ActiveDocument.Shapes(1)
oCtr.OLEFormat.Object.Caption = ""
oCtr.OLEFormat.Object.Width = 0
oCtr.OLEFormat.Object.Height = 0
End Sub

The following code makes the control visible again in the form:

Sub ShowResetCommand()
Dim oCtr
Set oCtr = ActiveDocument.Shapes(1)
oCtr.OLEFormat.Object.Caption = "Reset Form"
oCtr.OLEFormat.Object.LockAspectRation = False
oCtr.OLEFormat.Object.Height = 24
oCtr.OLEFormat.Object.Width = 72
End Sub

Here is the proble. The control appears 72 picas high and 72 picas wide.
If I change the order of the height and width commands above then the
control appears as 24 picas high and 24 picas wide.

There is no intellisense with the .Object so I am at a loss as to what
command line I need.

Thanks.
 
M

Mo

Maybe it is a misspelling

oCtr.OLEFormat.Object.LockAspectRation = False
vs.
oCtr.OLEFormat.Object.LockAspectRatio = False
 
H

Helmut Weber

Dear Submariner,

not an explanation, just a solution, hopefully.
Just address the shape, not the OLEFormat.object.

Sub HideResetCommand()
Dim oCtr
Set oCtr = ActiveDocument.Shapes(1)
oCtr.OLEFormat.Object.Caption = ""
oCtr.Width = 0
oCtr.Height = 0
End Sub

Sub ShowResetCommand()
Dim oCtr
Set oCtr = ActiveDocument.Shapes(1)
oCtr.OLEFormat.Object.Caption = "Reset Form"
oCtr.LockAspectRatio = msoFalse
oCtr.Height = 24
oCtr.Width = 72
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top