Section Page Break
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Section Page Break
I was first using a combination of different docm’s to generate a single report but that became a real pain with linking issues so I then combined them into a single docm. Separating each previous docm by using a section page break. Is it possible to select different page breaks to print by using let say a checkbox approach? I’m new to page breaks and I’m trying to see if this will be a good way to go.
-
- Administrator
- Posts: 78527
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Section Page Break
If you create a userform with as many check boxes as you have sections, say CheckBox1 to CheckBox10, you can assemble a string that tells Word what to print:
If I remember correctly, the string strSections should not be more than 255 characters in length.
Code: Select all
Dim i As Integer
Dim strSections As String
' Loop through check boxes to assemble string
For i = 1 To 10
If Me.Controls("CheckBox" & i) = True Then
strSections = strSections & ",s" & i
End If
Next i
If strSections = "" Then
MsgBox "Please select at least one section", vbExclamation
End If
' Remove first comma
strSections = Mid(strSections, 2)
' Print specific sections
ActiveDocument.PrintOut Range:=wdPrintRangeOfPages, Pages:=strSections
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: Section Page Break
WOW Hans
That work like magic. I didn’t even have to assign anything to the checkboxes, so I'm taken it that each check in numeral order are the same as page break order.
Now I have another question in regards to page breaks. Let say that I am beginning to start a new report. I have 20 possible selections (Page Breaks) but I only need 12 for this particular report, once again is it possible to use checkboxes to select only the page breaks needed and then maybe hide or delete the remaining. And of course it would probably be wise to have it be a copy of the original docm
That work like magic. I didn’t even have to assign anything to the checkboxes, so I'm taken it that each check in numeral order are the same as page break order.
Now I have another question in regards to page breaks. Let say that I am beginning to start a new report. I have 20 possible selections (Page Breaks) but I only need 12 for this particular report, once again is it possible to use checkboxes to select only the page breaks needed and then maybe hide or delete the remaining. And of course it would probably be wise to have it be a copy of the original docm
-
- Administrator
- Posts: 78527
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Section Page Break
I'd save your document as a macro-enabled template (.dotm).
Double-clicking a template from Windows Explorer creates a new document based on the template; when the user saves it the Save As dialog will be displayed. The template will not be overwritten.
You could use code like this:
Double-clicking a template from Windows Explorer creates a new document based on the template; when the user saves it the Save As dialog will be displayed. The template will not be overwritten.
You could use code like this:
Code: Select all
Dim i As Integer
' Loop backwards through the check boxes
For i = 20 To 1 Step -1
' Delete section if the corresponding check box is off (clear)
If Me.Controls("CheckBox" & i) = False Then
ActiveDocument.Sections(i).Range.Delete
End If
Next i
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: Section Page Break
Thank you Hans
I shall take this for a spin around the block and see how she's works
As always most greatly appreciated
I shall take this for a spin around the block and see how she's works
As always most greatly appreciated
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: Section Page Break
Hi Hans
I now have question that may refers to both lines of code that you have provided in your previous post on this thread.
On this docm, the first 3 section page breaks are client information log, an invoice and a in the field work sheet. All 3 will be needed with each report.
So on the first line of code that you provided that would print select page breaks using a checkboxes
Would I then change
For i = 1 To 10
To
For i = 4 To 10
And on the second line of code, change
For i = 20 To 1 Step -1
To
For i = 20 To 4 Step -1
I now have question that may refers to both lines of code that you have provided in your previous post on this thread.
On this docm, the first 3 section page breaks are client information log, an invoice and a in the field work sheet. All 3 will be needed with each report.
So on the first line of code that you provided that would print select page breaks using a checkboxes
Would I then change
For i = 1 To 10
To
For i = 4 To 10
And on the second line of code, change
For i = 20 To 1 Step -1
To
For i = 20 To 4 Step -1
-
- Administrator
- Posts: 78527
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Section Page Break
Yes, indeed. Make sure that you remove, disable or hide the first three check boxes (named CheckBox1 through CheckBox3), not the last three or others.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: Section Page Break
Once again thank you very much Hans
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: Section Page Break
Hi Hans
I have another question, and I’m probably reaching for straws here, is it possible to use code that will allow me to view only a single section page break at a time, thus hiding other section page breaks from view, until of course they are selected. Or what might you suggest, I’m all ears
I have another question, and I’m probably reaching for straws here, is it possible to use code that will allow me to view only a single section page break at a time, thus hiding other section page breaks from view, until of course they are selected. Or what might you suggest, I’m all ears
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78527
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Section Page Break
It is possible to hide text in Word, but users can decide for themselves whether hidden text is displayed on screen or not:
It is not considered polite to change this setting.
I think this option would be more work than it's worth...
It is not considered polite to change this setting.
I think this option would be more work than it's worth...
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: Section Page Break
Thank you Hans
I'll just keep it simple
I'll just keep it simple