Consulting

Results 1 to 3 of 3

Thread: Setup page from excel to word

  1. #1
    VBAX Mentor
    Joined
    Dec 2009
    Posts
    416
    Location

    Setup page from excel to word

    Hello

    I try to setup an page from excel to word but I received the following error:

    "object doesn't support this property or method"

    search on net and seams that .CentimetersToPoints need to be WordDoc.CentimetersToPoints

        With WordDoc.PageSetup
            .TopMargin = WordDoc.CentimetersToPoints(4.5)
            .BottomMargin = WordDoc.CentimetersToPoints(3.7)
            .LeftMargin = WordDoc.CentimetersToPoints(2.5)
            .RightMargin = WordDoc.CentimetersToPoints(1#)
            .Gutter = WordDoc.CentimetersToPoints(0)
            .HeaderDistance = WordDoc.CentimetersToPoints(1.25)
            .FooterDistance = WordDoc.CentimetersToPoints(0.39)
            .PageWidth = WordDoc.CentimetersToPoints(21)
            .PageHeight = WordDoc.CentimetersToPoints(29.7)
    End With
    I putted like this (WordDoc.CentimetersToPoints) but the same error. the rest of the code is going. only this part is not ok. what it is wrong?

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
            With WordDoc.PageSetup
                .TopMargin = WordDoc.Application.CentimetersToPoints(4.5)
                .BottomMargin = WordDoc.Application.CentimetersToPoints(3.7)
                .LeftMargin = WordDoc.Application.CentimetersToPoints(2.5)
                .RightMargin = WordDoc.Application.CentimetersToPoints(1#)
                .Gutter = WordDoc.Application.CentimetersToPoints(0)
                .HeaderDistance = WordDoc.Application.CentimetersToPoints(1.25)
                .FooterDistance = WordDoc.Application.CentimetersToPoints(0.39)
                .PageWidth = WordDoc.Application.CentimetersToPoints(21)
                .PageHeight = WordDoc.Application.CentimetersToPoints(29.7)
            End With
    Just a suggestion, but when it is part of the code that is referring to an operation in Word, you may wish to post the code and question in that forum. TinBender and a number of others can no doubt be of better help.

    Mark

  3. #3
    VBAX Mentor
    Joined
    Dec 2009
    Posts
    416
    Location
    The code is in excel for word.. so if it is starting from excel, it is for excel (I will keep in my mind for the future post).

    Mark, thanks (it is working)

Posting Permissions

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