Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    InchesToPoints (WordXP)

    I was having trouble today with some VBA code that updates some PageSetup settings. My queue is the left margin. If it's not 1.8", then I proceed with the update. But VBA seemed to refused to recognize that the left margin did, sometimes, equal InchesToPoints (1.8). I displayed the left margin in a MsgBox just before the If statement, and it was 1.8.

    I now realize that the following code proves false, even though I've just set the margin:

    ActiveDocument.PageSetup.LeftMargin = InchesToPoints(1.8)
    If ActiveDocument.PageSetup.LeftMargin = InchesToPoints(1.8) Then
    MsgBox "LM = 1.8"
    Else
    MsgBox "LM not 1.8"
    End If

    If I change 1.8 to 1.9 (all instances), the statement proves True.

    I understand that VBA is looking at points as opposed to inches, but I'm wondering what the reason might be that 1.8 does not equal 1.8... especially immediately after I've just used VBA to set the margin.

    Thanks,
    Richard Barrett

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: InchesToPoints (WordXP)

    I can't think of any reason that 1.9 inches should work but not 1.8. Perhaps, though, you might consider rounding the value to the nearest integer when you do the assignment and comparison.

    <code>Round(InchesToPoints(1.8), 0)</code>

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: InchesToPoints (WordXP)

    Thanks. I t gave your suggestion a try, rounding to 1 place, and that worked well. I ended up using the exact points, 129.6, and that worked well. I think you method may provide better leeway in the long run.

Posting Permissions

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