Page 1 of 3 123 LastLast
Results 1 to 15 of 35
  1. #1
    5 Star Lounger
    Join Date
    Mar 2004
    Posts
    924
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Printing out range of documents (2000)

    Is is possible to print out a range of documents, without actually opening the documents, as this is very time consuming.

    What l would like to do is to open the range of documents in the screen shot without actually opening the documents themselves.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Printing out range of documents (2000)

    > What l would like to do is to open the range of documents in the screen shot without actually opening the documents themselves

    Huh? How can you open documents without opening them?

    If you want to print them, you could use VBA code. Put the following code at the beginning of a module:
    <code>
    Private 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

    Private Const SW_SHOWNORMAL = 1

    Public Sub PrintOneFile(fn As String)
    Dim lngResult As Long
    lngResult = ShellExecute(0&, "Print", fn, 0&, 0&, SW_SHOWNORMAL)
    If lngResult <= 32 Then
    MsgBox "Something went wrong.", vbExclamation
    End If
    End Sub

    Sub PrintFiles()
    Dim lngRow As Long
    For lngRow = 3 To 13
    PrintOneFile Range("C" & lngRow)
    Next lngRow
    End Sub
    </code>
    The macro to run is PrintFiles. Change the bounds 3 and 13 and the column "C" to what you need.

  3. #3
    5 Star Lounger
    Join Date
    Mar 2004
    Posts
    924
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing out range of documents (2000)

    Can you explain in a bit more details, as to what you mean?

    i.e. how do l access the module and where the coding goes in the module?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Printing out range of documents (2000)

    From Excel, select Tools | Macro | Visual Basic Editor.
    Then select Insert | Module to create a new module.
    Copy the code I posted, and paste it into the module.
    Change the PrintFiles macro to match your situation. For example, if the file names are in rows 10 through 50, change the line

    For lngRow = 3 To 13

    to

    For lngRow = 10 To 50

    And if the file names are in column M, change the line

    Range("C" & lngRow)

    to

    Range("M" & lngRow)

    When done, switch back to Excel. You can run the PrintFiles macro as follows:
    Select Tools | Macro | Macros...
    Click on PrintFiles in the list of macros.
    Click Run.

    You can also assign the macro to a command button from the Forms toolbar, etc.

  5. #5
    5 Star Lounger
    Join Date
    Mar 2004
    Posts
    924
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing out range of documents (2000)

    I have tried this and get an error, see attachment.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Printing out range of documents (2000)

    The code has been messed up by your browser. It should look like the screenshot below.

  7. #7
    5 Star Lounger
    Join Date
    Mar 2004
    Posts
    924
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing out range of documents (2000)

    I have resolved this l am now getting the following error.
    see attachment.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Printing out range of documents (2000)

    That probably means that there is no file with the specified path/name.

  9. #9
    5 Star Lounger
    Join Date
    Mar 2004
    Posts
    924
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing out range of documents (2000)

    Can you tell me where in the file l edit the path name , as l cannot see where to edit this in the coding.

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Printing out range of documents (2000)

    Justin,

    This isn't going to work. With all due respect, I think you should take courses in Excel and Excel VBA before continuing.

  11. #11
    5 Star Lounger
    Join Date
    Mar 2004
    Posts
    924
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing out range of documents (2000)

    Is there any way you can tell me where the path name goes in this coding.
    I think l should be able to work it out from there.
    As this macro would really really help me a lot.

    I agree l need to take a course in VBA.

  12. #12
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Printing out range of documents (2000)

    The path name is not in the coding, it is in the spreadsheet (eg like in your first screenshot), the code just looks in your worksheet.

    Either the pathname and file is incorrect, or you have the code looking in the wrong location.

    Steve

  13. #13
    5 Star Lounger
    Join Date
    Mar 2004
    Posts
    924
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing out range of documents (2000)

    Thanks for that, I am still strugging slightly but feel it is something very simple, but cannot see what it is.
    Can you tell me where l could possibly look?

  14. #14
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Printing out range of documents (2000)

    Justin

    Take the hint buddy, Hans has stated in his messages to you that the cell has the hyperlink reference to your document. The code loops through your list in the spreadsheet and then prints it off.... The code works, I have played with it and it works...<big>the problem is your end</big>...it appears your references to the documents are wrong.......The admin guys here are fantastic but they are not clairvoyants and magicians
    Jerry

  15. #15
    5 Star Lounger
    Join Date
    Mar 2004
    Posts
    924
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing out range of documents (2000)

    Jerry,

    I cannot work out where the references to the document are?
    The module appears to be in the correct spreadsheet, l am a little confused as to where l need to look.
    Would a screenshot be of assistance.

Page 1 of 3 123 LastLast

Posting Permissions

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