set margins for 1st page different than the rest of the pages - vba

I need to set the margins differently for the first page than the rest of the pages.
I've messed around with inserting section breaks (as from what I've read is that Word creates a section break when you choose to apply "this point forward" from the Page Setup Margins tab, but I can't seem to consistently create a continuous section break at the start of the second page.
If not section breaks, any other way would be fine. Need to adjust margins to match new letterhead design for a bunch of existing documents so am planning on fixing the margins in a sub-routine when the print button is clicked (part of another macro).

A Continuous Section Break is used to allow multiple sets of margins within the same page. A Next Page Section Break, which has the properties of both a section break and a page break, will allow one set of margins for the first page and another set of margins for all pages following it. One way it can be created is like this:
Selection.InsertBreak Type:=wdSectionBreakNextPage
Now here's where it gets tricky. Word has two different types of page breaks: Automatic and Manual. Automatic page breaks get created when text no longer fits on a page and Word automatically generates a new page. If the documents you are reformatting via the macro have automatic page breaks, inserting the Next Page Section Break at the end of the first page will cause Word to delete its Automatic Page Break (using the Next Page Section Break to keep the pages separate) and any margin changes you make to the first page will not carry over to the following pages. However, if the documents contain a Manual Page Break between pages one and two, inserting the Next Page Section Break will create a blank second page. As such, if this is a possibility, code will need to be written to detect the Manual Page Break and delete it after the Next Page Section Break has been inserted.

Letterhead layouts and Word can be really difficult and tricky if you need other values only on the first page. In my practice, I find often letterheads with graphical elements in a right margin of the first page up to a certain heigth, e.g. a list of partner names or business information. So on the first page the right margin should be 6 cm, while on all following pages it should be 2,5 cm.
Using a section break is not possible due to the fact that it moves while the user inserts text.
I've used the following approach with some success:
Create a text box in the first page header which is sufficiently big to occupy the space needed. Setup the property for "Text Wrapping" = Square, so that text cannot overlap the box.
Of course you can insert the text box also into the document body to have that effect. Unfortunately, users can then touch the text box easily in a mouse action, and move it to another position. If you put it into the first page header, it will appear only on the first page, and will appear "in the background" of the page. The user can enter text in the document body, but it will stop before the text box, which simulates a right margin on the first page.

Related

How do I prevent the last sentence in each MS Word page from breaking to the next page?

I want the last sentence in the page, to be a non-breaking sentence in MS Word.
"Page break before" option does not work for me. Because, It moves the whole paragraph to the next page. I want to break the page down just right after the last punctuation mark at the end of each page. In other words, sentences should not overflow to the next page.
So, I think I need to detect the last punctuation mark in the page and insert a [Enter]/[Page Break] after that. How can I do this in VB.NET.
Or any other simpler solution?
How much text is shown on a page is determined dynamically by Word, based on the margin settings and the current printer-driver. Word calculates the layout dynamically and it's not possible to force specific content into a page, as is possible with page layout software. Increasing the margin settings would be a possible approach, but this would apply to the entire document or entire Section.
To prevent single lines from being split off, Word has the following settings in the Paragraph Format/Line and Page Breaks dialog box, with equivalents in the object model:
Window/Orphan control (active by installation default): - Paragraph.Format.WidowControl (boolean)
True if the first and last lines in the specified paragraph remain on
the same page as the rest of the paragraph when Word repaginates the
document.
Keep lines together - Paragraph.Format.KeepTogether
True if all lines in the specified paragraphs remain on the same page
when Microsoft Word repaginates the document.
The only way to force a page's content would be to put the content in a Drawing SuatoShape TextBox (Shape.Text = msoTextBox). Draw the text box large enough for all the content - it can go outside a margin setting - and insert the content. But note that Word's normal editing behavior will not be the same. For example, adding or deleting content on a previous page will not change the content in the text box and could end up "kicking" it to another page, entirely, with unwanted white space on other pages.

How to break a SSRS Report page only in PDF?

I am using BIDS to develop a report that needs to be configured in one page when viewed on the internet explorer but still needs page breaks for good display in PDF when exported. The problem is that when i insert page breaks beetween tables another page is added to the report and i only want that in the PDF. Is there any way i can insert page breaks in the PDF but not on the report view itself?
You can achieve this by setting the InteractiveSize property to the wanted value (0 can be used to make it infinite).
If you wish to keep the same width, then you should only change the Height.
Edit: Defining specific page breaks will always force the viewer to use paging as well. This was implemented to improve the performance of large reports to allows users to begin viewing the initial pages of the report while waiting for additional pages to become available.
HTML and Excel output shows a report as a single page if there are no
page breaks. If you do specify InteractiveHeight and InteractiveWidth,
the HTML and Excel output formats render reports using soft page
breaks. Soft page breaks are placed on a page using an estimated page
size, which makes the size of the reports less exact than reports
produced by an output format that supports page size. Soft page breaks
are calculated at run time by the control. Although it is not
recommended, you can disable soft page breaks by setting
InteractiveHeight to 0.
Source: Defining Page Size and Page Breaks in a ReportViewer Report
As described in the quote above, the InteractiveHeight is used to apply soft page breaking when using the report viewer. So the solution is to only use soft page breaks.
You can manipulate your report to break correctly with paging without using hard page breaks by wrapping the wanted blocks inside rectangles. These rectangles you then re-size to be the size of a page and set the property KeepTogetheras true.
This will try to fit the content of the rectangles on the same page, adding a break when you reach the next rectangle. Because your InteractiveSize has no limit, this will not be displayed in the report viewer.

ssrs report viewer vs exported pdf page count

The number of pages displayed when viewed in ReportViewer and in exported PDF are differing.
Eg: 50 records are shown in one single page of Report Viewer. But when Exported to PDF 45 reords come in page 1 and the remaining come in page 2.
Soution Tried:
1)Removed Top and Bottom Margins.
2)Reduced "Interactive Page Size" to match the page count.
But it is not consistent, as it is behaving differently with different number of records.
Can anyone tell me how should I proceed to achieve sync between the ReportViewer and exported PDF ?
Thanks
Short answer - you can't do what you are trying to do: the different renderers handle pagination differently, but appropriately for their output.
The HTML renderer is optimised for screen-based reading and generally allows more content per page than the print renderer does as the print renderer is constrained by the paper size that it formats to. Thus the HTML renderer allows more content on fewer pages for a better browser experience whereas the print and PDF renderers have to conform strictly to the page length.
The best illustration of this is the Excel renderer - the Excel renderer renders the entire report onto a single worksheet in most cases (for reports with grouping and page breaks set on the group footer it will render each group on its own worksheet). You wouldn't want the Excel renderer to artificially create worksheets to try to "paginate" your report or to put it all in one worksheet but insert the header into the spreadsheet rows every "page". It does the appropriate thing which is to include all the data in one big worksheet even though that may be logically thought of as one big "page".
The HTML renderer page length is determined (more accurately, influenced) by the InteractiveHeight attribute of the report (in the InteractiveSize property in the Properties pane for the report). However, the interactive height is an approximation rather than a fixed page break setting and your page breaks may still not conform to the print version even if you set InteractiveHeight to the same length as your target page length. This is because the HTML renderer will vary the page length to group the data together better so the interactive page breaks happen around about, but not always exactly, where the interactive height is set.
This is what is happening in your scenario where the report viewer shows 50 records on one page but the PDF has 45 on the first page and 5 on the second page. The report viewer is making the decision that since there are only a few records left to display it will just include them all on the one page rather than force the user to scroll even though the interactive height will be exceeded. Thus you get a better user experience but a variance in pages between renderers. The important thing about the report is the data and the experience with working with that data in that renderer, not that the pages are the same length no matter how you look at it.
See this discussion of rendering behaviour for more information on why what you are trying to achieve isn't achievable. Just educate your users that the browser pagination is optimised for their viewing pleasure.

Expanding textbox stopping page breaks in PDF conversion

I have a simple report that has an image and a textbox within the body (a rectangle). The textbox is set to 'Allow Height to Increase'. The rectangle is set to 'Page Break After'.
Normally this works fine if the contents of the textbox span a few lines. However, when the textbox expands over multiple pages the Page Break is ignored. This only happens when exporting to PDF, yet works as expected in Preview mode.
I'm hoping someone has some insight into this behaviour or can recommend an alternative page structure that will achieve the desired results.
Could you please check the Rectangles property
kept contents together on a single page
in a parent Rectangle object, this will always keep items together where possible.
You could also set page setup settings (margins, gutters, printable page size...) to make sure that they are not affects on exported PDF document.

SSRS05 A one page report in preview shows a second page with only footer in print layout

I have a user sign off report where it shows a users rights/access to the system which all fits nicely onto one page when I hit preview. However when I then go to print layout it shows me two pages with the second page only containg the footer.
Any ideas please?
Are you sure the page size matches the paper size?
If so, have you tried setting the page footer's PrintOnLastPage property to false? Then again, if you really need that footer to be there (seeing that there's only one page), you might have to try fiddling with the margins to get it to fit within the first page.
The report size at design time, plus the margins must be less than the paper size. Sometimes you can have a report that is too wide that is essentially generating a blank page "to the right" rather than underneath the first page.
Yes I have scrunched it all up so that it is WELL within the page size and I have tried all combinations of Footers (and headers).
It is a slightly wierd report in that it has fields that need to grow to show all the information and a small table too, but even at full growth the data looks like it fits on one page (in preview in Visual Studio) but as soon as it goes to print preview and printing it reverts to two pages.
Make sure you do not have extra area to the right of the last field of the report.
Are you sure you've adjusted the report's display size in the property sheet, too?
Hope this helps,
Bill