Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7932899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:09:29+00:00 2026-06-03T21:09:29+00:00

Im working with vb.net and microsoft word using Microsoft.Office.Interop.Word and everything is fine. My

  • 0

Im working with vb.net and microsoft word using Microsoft.Office.Interop.Word and everything is fine. My only problem is I cant find a way to change the default page size printing setting from “letter” to “A4”.
This code was doing the job for Crystal reports but isnt doing it for Word

Dim pp As New System.Drawing.Printing.PrintDocument
For i = 0 To pp.DefaultPageSettings.PrinterSettings.PaperSizes.Count - 1
If pp.DefaultPageSettings.PrinterSettings.PaperSizes.Item(i).Kind = System.Drawing.Printing.PaperKind.A4 Then
pp.DefaultPageSettings.PaperSize = pp.DefaultPageSettings.PrinterSettings.PaperSizes.Item(i)
Exit For
End If
Next

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:09:31+00:00Added an answer on June 3, 2026 at 9:09 pm

    Ref: http://social.msdn.microsoft.com/forums/en-US/vsto/thread/45152591-1f3e-4d1e-b767-ef030be9d9f2

    Since page size can vary from section to section, the best thing is to set the PageSetup properties of the Document.Section object. For example, you can loop through all the sections of the document:

    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        Application app = Globals.ThisAddIn.Application;
        Word.Document doc = app.ActiveDocument;
        foreach (Section section in doc.Sections)
        {
            section.PageSetup.PaperSize = WdPaperSize.wdPaperA4;
        }
    }
    

    Adding locic to set paper size when a document is created or opened is up to you, I’m guessing you’ll need to determine if the document being opened has purposely been saved in a non-A4 size.

    EDIT: This does work, I dont know what you mean with the comment ThisAddIn isnt a member or Globals and ActiveDocument isnt a member of Application in VB.NET – you cant skip these top two lines, here is the VB.Net version:

    Private Sub ThisAddIn_Startup(sender As Object, e As System.EventArgs)
        Dim app As Application = Globals.ThisAddIn.Application
        Dim doc As Word.Document = app.ActiveDocument
        For Each section As Section In doc.Sections
            section.PageSetup.PaperSize = WdPaperSize.wdPaperA4
        Next
    End Sub
    

    All you need to do is > Visual Studio > Create a New Prorject > Office > Word 2010 (or 2007) Add-In and paste in the above code. Here is a screenshot showing it works with A4 and Letter:

    enter image description here

    The only issue you may face is when the Printer doesn’t have the size paper you get this error: Requested PaperSize is not available on the currently selected printer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working With Microsoft Word VBA,macros,.net My question : Is there way to
My system has Office2007. And i use VB.Net to automate word. Everything works fine.
I have developed a word 2007 add-in using Visual Studio 2010, everything is working
Just started working with .NET and MVC(1). I'm having a problem wherein in my
Working on a website http://www.ArenaText.com written in asp.net with Microsoft AJAX control toolkit. iPad
Microsoft provides a number of command line tools for working with asp.net applications. I
I am trying to call MSBuild from a command line. Everything was working fine
I am working in a Microsoft .NET shop where it is okay to use
I am just working on .NET for the past six month.I am using VS
I'm working on ASP.NET MVC2 project. everything was OK in the last months, today

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.