Results 1 to 4 of 4
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    frame height change to cm (word97 sr2b)

    I'm working with a number of frames in a document.
    So I know which frame I'm working with I want to extract the position, height, width etc.

    my code:
    With Selection.Frames(1)
    .Select
    x = .Height
    End With

    My current frames height is 17.61 cm
    For this frame the x is returning 499.25. I know never assume, however I assume this would be the points measurement yes?
    Is there a way I can extract the frames height in cm's?

    many thanks
    Diana

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: frame height change to cm (word97 sr2b)

    Debug.Print PointsToCentimeters(499.25) gives a value of 17.61243

    For any other type of object I'd suggest that you use the .Name property to identify it, I'm really surprised that a Frame doesn't have a .Name property.

    StuartR

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: frame height change to cm (word97 sr2b)

    Hi Stewart

    Yes the frame doesnt have a .name property, so I find it difficult to work with & manipulate frames - or any graphics within word vba.
    my code below:
    even thought my frame size is 11.cm
    its still going into the 1st test ie 'original frame' as the value is still in points ie 311.pts.
    Is there a way I can obtain & store the debug print value into a variable?

    Diana

    With Selection.Frames(1)
    .Select
    x = .Height
    End With

    Debug.Print PointsToCentimeters(x) '; gives; a; Value; of; 17.61243

    If x >= 17 Then
    MsgBox With Selection.Frames(1)
    .Select
    x = .Height
    End With

    Debug.Print PointsToCentimeters(x) '; gives; a; Value; of; 17.61243

    If x >= 17 Then
    MsgBox "orginial frame"
    ElseIf (x >17) And (x < 11.0018) Then
    MsgBox "amended frame"
    End If
    ElseIf (x < 17) And (x > 11.0018) Then
    MsgBox "amended frame"
    End If

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: frame height change to cm (word97 sr2b)

    This seems to do what you are asking for...

    Sub Test()
    Dim sHeight As Single
    sHeight = PointsToCentimeters(Selection.Frames(1).Height)

    If sHeight > 17 Then
    MsgBox "Big frame: " & Str$(sHeight)
    Else
    MsgBox "Small frame: " & Str$(sHeight)
    End If

    End Sub

    StuartR

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •