View Single Post
 
Old 03-30-2017, 12:55 PM
Benbon Benbon is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Mar 2017
Posts: 2
Benbon is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
To print specified Sections, simply supply the Section #s to the print dialogue, prefixed by 's'. For example, to print Sections 1, 2, 4, 5, 6, 7 & 9, you might input "s1-s2,s4-s7,s9" in the print dialogue, thus:
Code:
With Dialogs(wdDialogFilePrint)
  .Background = True
  .Pages = "s1-s2,s4-s7,s9"
  .Execute
End With
to print the document without even displaying the dialogue.

For further info on printing nominated ranges across Sections, see: https://support.microsoft.com/en-au/...d-in-word-2003
Thank you for your response. I did try the code that was provided and for some reason, it did not recognize the sections. Instead, it would attempt to print the entire document. Also, there are many sections in this manual. I'm looking for a way to group them together. Here's an example: Sections 1 and 2 are always needed no matter what selection is made. Section 3 can be left out of printing entirely, and then section 4 through 4.4 is needed. Section 4.5 contains the specific information where the user will be selecting their state. It's broken down as 4.5.1 CA, 4.5.2 TX, 4.5.3 FL and so on. So essentially, if the user selects 'CA' from my drop down form, the code would initialize printing of Sections 1-2, 4-4.4, and 4.5.1.

I believe the code should be written on the frm under the cmdok; however, I'm not sure as I was unable to get it to run. I have backed out the additional code that I was tinkering with (since it was not working) and brought it back to basics. I have also removed the majority of the states to shorten the code for posting here. I'm really trying to figure out where to go from here and having a tough time. I've been researching VBA each day and on the weekends but clearly I have a long way to go. I apologize upfront for my lack of skill with this software. Here is what I have:

modMain:

Sub CallUF()
Dim oFrm As frmSites
Set oFrm = New frmSites
oFrm.Show
Unload oFrm
Set oFrm = Nothing
lbl_Exit:
Exit Sub
End Sub
Sub PrintOut()
With Dialogs(wdDialogFilePrint)
.Background = True
.Pages = "s1-s2, s4-s5"
.Execute
End With
End Sub

frmSites:

Option Explicit
Private Sub cmdCancel_Click()
Me.Hide
End Sub
Private Sub cmdOK_Click()
Me.Hide
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "Atlanta, GA"
.AddItem "Bethesda, MD"
End With
lbl_Exit:
Exit Sub
End Sub
Reply With Quote