none
Looking for equivalent to the PageSize registry key in VBA RRS feed

  • Question

  • Where is this key in the object model?  I basically want to pull this value generically (instead of specific to the Office version 14).

    [HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Word\Wizards] "PageSize"="Letter"


    adam
    Tuesday, April 5, 2011 9:33 PM

Answers

  • Hi Adam,

    Does the 'PaperSize' property do what you want? For example:
    Msgbox ActiveDocument.PageSetup.PaperSize
    where:
      0  =  wdPaper10x14
      1  =  wdPaper11x17
      2  =  wdPaperLetter
      3  =  wdPaperLetterSmall
      4  =  wdPaperLegal
      5  =  wdPaperExecutive
      6  =  wdPaperA3
      7  =  wdPaperA4
      8  =  wdPaperA4Small
      9  =  wdPaperA5
    10  =  wdPaperB4
    11  =  wdPaperB5
    12  =  wdPaperCSheet
    13  =  wdPaperDSheet
    14  =  wdPaperESheet
    15  =  wdPaperFanfoldLegalGerman
    16  =  wdPaperFanfoldStdGerman
    17  =  wdPaperFanfoldUS
    18  =  wdPaperFolio
    19  =  wdPaperLedger
    20  =  wdPaperNote
    21  =  wdPaperQuarto
    22  =  wdPaperStatement
    23  =  wdPaperTabloid
    24  =  wdPaperEnvelope9
    25  =  wdPaperEnvelope10
    26  =  wdPaperEnvelope11
    27  =  wdPaperEnvelope12
    28  =  wdPaperEnvelope14
    29  =  wdPaperEnvelopeB4
    30  =  wdPaperEnvelopeB5
    31  =  wdPaperEnvelopeB6
    32  =  wdPaperEnvelopeC3
    33  =  wdPaperEnvelopeC4
    34  =  wdPaperEnvelopeC5
    35  =  wdPaperEnvelopeC6
    36  =  wdPaperEnvelopeC65
    37  =  wdPaperEnvelopeDL
    38  =  wdPaperEnvelopeItaly
    39  =  wdPaperEnvelopeMonarch
    40  =  wdPaperEnvelopePersonal
    41  =  wdPaperCustom


    Cheers
    Paul Edstein
    [MS MVP - Word]
    • Proposed as answer by Bruce Song Tuesday, April 12, 2011 1:18 AM
    • Marked as answer by Bruce Song Friday, April 15, 2011 2:00 AM
    Wednesday, April 6, 2011 4:08 AM

All replies

  • Hi Adam,

    Thank you for posting.

    As far as I know, there does not exist the API about registry key in object model. If we want to change the registry value, we can use Windows API, please take a look at this KB article:http://support.microsoft.com/kb/145679 which introduces how to use the registry API to save and retrieve setting.

    Hope this article can help you and feel free to follow up.

    Best Regards,

     


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, April 6, 2011 2:58 AM
  • Hi Adam,

    Does the 'PaperSize' property do what you want? For example:
    Msgbox ActiveDocument.PageSetup.PaperSize
    where:
      0  =  wdPaper10x14
      1  =  wdPaper11x17
      2  =  wdPaperLetter
      3  =  wdPaperLetterSmall
      4  =  wdPaperLegal
      5  =  wdPaperExecutive
      6  =  wdPaperA3
      7  =  wdPaperA4
      8  =  wdPaperA4Small
      9  =  wdPaperA5
    10  =  wdPaperB4
    11  =  wdPaperB5
    12  =  wdPaperCSheet
    13  =  wdPaperDSheet
    14  =  wdPaperESheet
    15  =  wdPaperFanfoldLegalGerman
    16  =  wdPaperFanfoldStdGerman
    17  =  wdPaperFanfoldUS
    18  =  wdPaperFolio
    19  =  wdPaperLedger
    20  =  wdPaperNote
    21  =  wdPaperQuarto
    22  =  wdPaperStatement
    23  =  wdPaperTabloid
    24  =  wdPaperEnvelope9
    25  =  wdPaperEnvelope10
    26  =  wdPaperEnvelope11
    27  =  wdPaperEnvelope12
    28  =  wdPaperEnvelope14
    29  =  wdPaperEnvelopeB4
    30  =  wdPaperEnvelopeB5
    31  =  wdPaperEnvelopeB6
    32  =  wdPaperEnvelopeC3
    33  =  wdPaperEnvelopeC4
    34  =  wdPaperEnvelopeC5
    35  =  wdPaperEnvelopeC6
    36  =  wdPaperEnvelopeC65
    37  =  wdPaperEnvelopeDL
    38  =  wdPaperEnvelopeItaly
    39  =  wdPaperEnvelopeMonarch
    40  =  wdPaperEnvelopePersonal
    41  =  wdPaperCustom


    Cheers
    Paul Edstein
    [MS MVP - Word]
    • Proposed as answer by Bruce Song Tuesday, April 12, 2011 1:18 AM
    • Marked as answer by Bruce Song Friday, April 15, 2011 2:00 AM
    Wednesday, April 6, 2011 4:08 AM
  •  1. the Wizards provided in Word 2003 are not provided in Word 2007 or 2010, although some of the Word 2003 ones may work in 2007/2010

     2. the Word 2003 Calendar Wizard (say), gets this item by using System.PrivateProfileString to retrieve the "PageSize" value under the HKCU subtree specified in a VBA Const as

    HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Wizards\

    i.e., even if you ran /that/ Wizard, it would not be getting its value from the Office\14.0 value of the key. But perhaps some of the other Wizards generate the "base key" more dynamically, taking account of the version of Word.

     3. I don't know what templates/addins supplied with Word 2010 might also use this key/value.

     4. This particular value does not necessarily correspond to any value you could extract using the Word object model. AFAIK Word does not store an application-wide "default page size" - the nearest thing you could probably retrieve is the page size of the normal.dot/.dotx/.dotm template. In theory even that could have sections predefined with different page sizes in them, though that would I think be rare. For that, opening a document based on Normal and using macropod's technique should get you the papersize of the first section in the document (assuming normal doesn't have an autonew macro that changes the papersize etc.

     

     


    Peter Jamieson
    Wednesday, April 6, 2011 11:56 AM
  • Paul,

    That value is what I found.  The other posts here make sense as well - since I'm converting some old template code to an add-in.  It's tricky.  I think the old code is really a bug and they should not have been using that reg key.

    adam


    adam
    Wednesday, April 6, 2011 12:28 PM
  • Hi Adam,

    Have you resolved your problem yet? If you still show any concern on the problem, just feel free to follow up.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, April 11, 2011 9:18 AM
  • No issues so far.  Using the value from the object model instead of the reg key.
    adam
    Monday, April 11, 2011 11:44 AM