Results 1 to 11 of 11
  1. #1
    New Lounger
    Join Date
    Jul 2006
    Location
    Melbourne, Victoria, Australia
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    run time error 4608 (English/Word/2003)

    I am getting a run time error "Value out of range" on the following line of code.

    This was recorded in Word and played back with an error. I have tried copying sample code from Help and it fails too. Am I missing a reference link?

    ActiveDocument.PageSetup.TopMargin = CentimetersToPoints(3.2)

    Thank you in advance.

    Carolin

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

    Re: run time error 4608 (English/Word/2003)

    It looks like a perfectly valid line of code, and works perfectly for me.

    Can you try breaking it down into two lines and see if they both fail.
    <code>
    MsgBox CentimetersToPoints(3.2)
    ActiveDocument.PageSetup.TopMargin = 90.70866
    </code>
    StuartR

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: run time error 4608 (English/Word/2003)

    I can execute that line without errors. Do you get the error in any document you try it in, or just in a specific document?

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    251
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Re: run time error 4608 (English/Word/2003)

    I've found the MS Help is wrong on this code.
    I can get it to work for me if I make the line
    ActiveDocument.PageSetup.TopMargin = CentimetersToPoints(3.2)
    into
    ActiveDocument.PageSetup.TopMargin = ActiveDocument.Application.CentimetersToPoints(3.2)
    I'd be interested to know if this helps
    Peter

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: run time error 4608 (English/Word/2003)

    You do not need Application.
    CentimetersToPOints is an Appplication and Global function that requires no qualifying object.

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    251
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Re: run time error 4608 (English/Word/2003)

    Yes, I know that's supposed to be true. But one application I've got throws a 'Remote server not found' error if I don't fully qualify it. I'm wondering if there are other, hidden occurences of CentimetersToPoints around.
    But changing it to Application. solved that problem. Thought it might work in this case as well.
    Peter

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: run time error 4608 (English/Word/2003)

    CentimetersToPoints is a method of both the Word and Excel application objects, so if you have references to both in Tools | References..., VBA may get confused if you don't qualify CentimeterToPoints.

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: run time error 4608 (English/Word/2003)

    The way to find out is to search for CentimetersToPoints in the Object Browser.
    If thgere's moret han one critter, they will all be listed.

  9. #9
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: run time error 4608 (English/Word/2003)

    An unqualified reference should resolve to that of the app which is running.
    To make sure, check the order in Tools | References.

  10. #10
    New Lounger
    Join Date
    Jul 2006
    Location
    Melbourne, Victoria, Australia
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: run time error 4608 (English/Word/2003)

    Thanks for all your pearls of wisdom.. Unfortunately in this case though I wasn't able to get this line of code to work. I found it worked on some documents but not others. I was trying to re-format documents based on a variety of templates, and I guess there is something resident in the template that is preventing me from running it. I was able to loop through the sections and apply the format that way. So I get an extra few lines of code. Things could be worse.

    Carolin

  11. #11
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: run time error 4608 (English/Word/2003)

    The value out of range has nothing to do with the CentimetersTo Points function.

    Rather, it has to do with the margin settings and the printer's capabilities.
    I would have to suspect some inconsistent settings for topmargin, headers and page height

Posting Permissions

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