Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi
    I have a 2007 Excel userform that has checkboxes (associated with different reports that are .docm) and a print button. I would like to have docm print in order “case 1, case 2, case3, and so on.”
    It use to work fine, but for some unknown reason it now jumps to Kitchen ?????? . with no special order with the rest of docm. All of the docm are very similar in may ways.
    Here is the code I use
    Code:
     Private Sub CommandButton2_Click()
        Set wdapp = CreateObject("word.application")    ' open Word
        MyPath = Replace(ThisWorkbook.FullName, ThisWorkbook.Name, "Inspection Reports\")
        If Dir(MyPath, vbDirectory) = "" Then
            MsgBox "Folder  " & MyPath & "  not found", vbCritical, "Error": Exit Sub
        End If
     
        For x = 1 To 18
            If Controls("checkbox" & x) Then
                Filename = MyPath & GetWordDocFileName(x)
                If Dir(Filename) <> "" Then    ' file exists
                    Debug.Print "Printing file  " & Filename
                    Set wdDoc = wdapp.Documents.Open(Filename)
                    wdDoc.PrintOut    'Default print
                    wdDoc.Close False    'Close without saving
                End If
            End If
        Next x
        wdapp.Quit    ' close Word
    End Sub
     
    Function GetWordDocFileName(ByVal index As Integer) As String
        Select Case index
            Case 1: GetWordDocFileName = "Cover Page.docm"
            Case 2: GetWordDocFileName = "Client Information.docm"
            Case 3: GetWordDocFileName = "Utilities.docm"
            Case 4: GetWordDocFileName = "Grounds.docm"
            Case 5: GetWordDocFileName = "Structure and Exterior.docm"
            Case 6: GetWordDocFileName = "Garage.docm"
            Case 7: GetWordDocFileName = "Roof.docm"
            Case 8: GetWordDocFileName = "Fireplace and Attic.docm"
            Case 9: GetWordDocFileName = "Bedroom(s).docm"
            Case 10: GetWordDocFileName = "Bathroom(s).docm"
            Case 11: GetWordDocFileName = "Interior.docm"
            Case 12: GetWordDocFileName = "Kitchen.docm"
            Case 13: GetWordDocFileName = "Kitchen Appliances.docm"
            Case 14: GetWordDocFileName = "Heating and Cooling.docm"
            Case 15: GetWordDocFileName = "Water Heater.docm"
            Case 16: GetWordDocFileName = "Pool  Spa.docm"
            Case 17: GetWordDocFileName = "Summary.docm"
            Case 18: GetWordDocFileName = "Additional Photo's.docm"
        End Select
    
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Have the documents coming "before" Kitchen.docm been renamed or moved?

  3. #3
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi HansV
    No the documents are in same location and the names are the same. I have modified and updated documents that it. It use to work great.
    When I'm ready to print I make my selections using the check boxes of which reports I wish to print and then select print, I can see it printing (PDF) in the back ground, but the first file that appears in the PDF Creator dialog is Kitchen ??????? I then have to manually adjust which order then combine and print.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I'm sorry, I have no idea why that would happen.

  5. #5
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you HansV for your time,
    I'll look over the .docm a little more closer to see if I find anything.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •