Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-28-2018, 07:01 AM
eshiffman eshiffman is offline Print documents based on boxes checked in word document Windows 7 32bit Print documents based on boxes checked in word document Office 2016
Novice
Print documents based on boxes checked in word document
 
Join Date: Mar 2018
Posts: 5
eshiffman is on a distinguished road
Default Print documents based on boxes checked in word document


I have a contract written in Word with check boxes for specific services. I would like to know if there is a way to print specific PDF documents based on what boxes are checked (but not have it print the documents for what is not selected).
Reply With Quote
  #2  
Old 03-28-2018, 03:12 PM
Guessed's Avatar
Guessed Guessed is offline Print documents based on boxes checked in word document Windows 10 Print documents based on boxes checked in word document Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Yes, you could write a macro to do that. If you intend to distribute that document to users then they would need to have
- the same folder structure and
- access to all the files and
- enable macros.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 03-29-2018, 07:54 AM
eshiffman eshiffman is offline Print documents based on boxes checked in word document Windows 7 32bit Print documents based on boxes checked in word document Office 2016
Novice
Print documents based on boxes checked in word document
 
Join Date: Mar 2018
Posts: 5
eshiffman is on a distinguished road
Default

How would I go about writing a macro?
Reply With Quote
  #4  
Old 03-30-2018, 03:02 AM
Guessed's Avatar
Guessed Guessed is offline Print documents based on boxes checked in word document Windows 10 Print documents based on boxes checked in word document Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

See the attached document. It contains three checkboxes with the associated pdf filename listed against the tag property for each one. The macro can be run by double clicking the first paragraph above the check boxes.

The PDF files will need to be in the same folder as the Word document.
Code:
Option Explicit

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
    ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
 
Public Function PrintPDF(xlHwnd As Long, FileName As String) As Boolean
  Dim X As Long
  
  On Error Resume Next
  X = ShellExecute(xlHwnd, "Print", FileName, 0&, 0&, 3)
  
  If Err.Number > 0 Then
    MsgBox Err.Number & ": " & Err.Description
    PrintPDF = False
  Else
      PrintPDF = True
  End If
  On Error GoTo 0
End Function

Sub PrintDocs()
  Dim aCC As ContentControl, sFile As String, sPath As String
  sPath = ActiveDocument.Path & Application.PathSeparator
  For Each aCC In ActiveDocument.ContentControls
    If aCC.Type = wdContentControlCheckBox Then
      If aCC.Checked Then
        sFile = sPath & aCC.Tag
        If Not PrintPDF(0, sFile) Then MsgBox "Printing failed: " & sFile
      End If
    End If
  Next aCC
End Sub
Attached Files
File Type: docm PrintDocsDemo.docm (60.0 KB, 19 views)
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 04-02-2018, 09:35 AM
eshiffman eshiffman is offline Print documents based on boxes checked in word document Windows 7 32bit Print documents based on boxes checked in word document Office 2016
Novice
Print documents based on boxes checked in word document
 
Join Date: Mar 2018
Posts: 5
eshiffman is on a distinguished road
Default

Nothing happens when I click in the document you sent me. What do you mean by click on the paragraphs?
Reply With Quote
  #6  
Old 04-02-2018, 04:17 PM
Guessed's Avatar
Guessed Guessed is offline Print documents based on boxes checked in word document Windows 10 Print documents based on boxes checked in word document Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Do you have pdfs in the same folder as the document?
Do those PDFs have names that match the tag properties of the checkboxes?
Is at least one of those check boxes checked?

Did you then double click the first paragraph in the document?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #7  
Old 04-04-2018, 08:41 AM
eshiffman eshiffman is offline Print documents based on boxes checked in word document Windows 7 32bit Print documents based on boxes checked in word document Office 2016
Novice
Print documents based on boxes checked in word document
 
Join Date: Mar 2018
Posts: 5
eshiffman is on a distinguished road
Default

Instead of having them print from another folder, could I like the checkboxes to print specific pages of the same document? (but only the pages that are checked)
Reply With Quote
  #8  
Old 04-04-2018, 05:39 PM
Guessed's Avatar
Guessed Guessed is offline Print documents based on boxes checked in word document Windows 10 Print documents based on boxes checked in word document Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Yes. I'm not going to create the code for you until you've made some effort and provided an effective example to work from. If you don't want to actually test solutions provided for the questions you ask then it is hardly worth our time when you decide to change direction completely.

Record a macro and send some pages to print. Have a look at the code that gets created and work out how you can adapt that.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #9  
Old 04-05-2018, 06:26 AM
eshiffman eshiffman is offline Print documents based on boxes checked in word document Windows 7 32bit Print documents based on boxes checked in word document Office 2016
Novice
Print documents based on boxes checked in word document
 
Join Date: Mar 2018
Posts: 5
eshiffman is on a distinguished road
Default

There is absolutely no reason to be so rude. You never asked me to provide an example to work from, nor did I ask you to create any kind of code. I have never recorded macros so I am sorry that I do not understand how to. Thank you for your time, but I will find help elsewhere.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Macro to select Checkbox after two boxes are checked in a series of checkboxes rsaini Word VBA 0 01-16-2018 11:57 AM
Total Checked FF Check Boxes CarlCR Word Tables 2 07-13-2016 12:01 PM
Template opens with userform ; non-checked boxes should lead to deletion of corresp paragraphs samszaf Word 1 09-07-2015 09:52 AM
how to show total of check boxes checked worder Word 16 03-10-2014 05:07 PM
Create makro that counts the number of checked tick boxes in a survey johannapaj Word VBA 0 09-05-2011 01:51 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:47 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft