Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word form within Access (2003 SP2)

    I am calling Word from within Access but am getting an error on some simple code.
    .
    This line works:
    appWD.ActiveDocument.PageSetup.Orientation = wdOrientLandscape
    Either of these lines (directly after the above line) cause the error below:
    appWD.ActiveDocument.Sections(1).PageSetup.TopMarg in = CentimetersToPoints(1)
    appWD.ActiveDocument.PageSetup.TopMargin = CentimetersToPoints(1)
    Error message:
    The remote server machine does not exist or is unavailable
    .
    appWD is set as a Word Application object.
    .
    Also getting the same error with these lines:
    appWD.ActiveDocument.PageSetup.LeftMargin = CentimetersToPoints(1)
    appWD.Selection.Tables(1).TopPadding = CentimetersToPoints(0)
    appWD.Selection.Tables(1).PreferredWidth = CentimetersToPoints(27)
    appWD.Selection.Tables(1)..Columns.PreferredWidth = CentimetersToPoints(2.2)
    Regards,
    Peter

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

    Re: Word form within Access (2003 SP2)

    Same error as with Excel in <post:=663,377>post 663,377</post:>: CentimetersToPoints is a Word method but you don't specify it as such. You must use appWd.CentimetersToPoints(1) etc.

  3. #3
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word form within Access (2003 SP2)

    I found the solution from within the Lounge in post I made in 2001.
    Need to precede CentimetersToPoints(1) with appWD.
    appWD.ActiveDocument.Sections(1).PageSetup.TopMarg in = appWd.CentimetersToPoints(1) works just fine!
    Regards,
    Peter

  4. #4
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word form within Access (2003 SP2)

    Thank Hans. We found it together.
    Regards,
    Peter

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

    Re: Word form within Access (2003 SP2)

    Whenever you use Automation to control one application from another in code, you should check very carefully that *all* items (properties, methods) from the called application correctly refer to the object they belong to, either directly or indirectly. Items without a dot . before them are suspect.

  6. #6
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word form within Access (2003 SP2)

    Thanks Hans. I can make Access VBA sing and dance (very lame dancing cf yourself). But on the rare occasions that I use Word or Excel VBA, I'm all at sea. Without macro recording, object exporer and most of all the Lounge, I wouldn't have a hope.
    Regards,
    Peter

Posting Permissions

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