Results 1 to 11 of 11
  1. #1
    Ajz1971 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    7

    Wink How to print off multiple word documents

    Hi All,

    I have a query that gives me a list of Linked Word.Doc Files (C:/Policies/Policy1.Doc…. C:/Policies/Policy2.Doc etc…) what I would like to do is be able to print off all documents automatically using VBA code that I can attach to the on click of a button…Is this possible?



    The query is named 'Staff Query'... The column of linked files is 'Field2'

    Big thanks for any reply in advance

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    https://bytes.com/topic/access/answe...ocument-access

    This looks like it


    Sent from my iPhone using Tapatalk

  3. #3
    Ajz1971 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    7
    thanks for the reply Andy...

    But the code given is only for a given file path... what i would like is for all paths (1 to maybe 100) in a query to be printed off with one click of the form button (user clicks button - vba runs the query and creates the list of file paths to the word documets - vba prints off each document without having to open MS Office Word)

    Thanks for the reply! ...

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

    How to print off multiple word documents

    Off top of head.

    Create a function to print file "c:\\path\name.doc called printfunction

    Qry opens a recordset

    Work through recordset
    Run printfunction

    until EOF is reached

    Should work


    Sent from my iPhone using Tapatalk

  5. #5
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    This will loop thru the records in your query (just thrown together, may need some tweaks!)

    Code:
        Dim rst As Recordset
        Set rst = CurrentDb.OpenRecordset("query1", dbOpenDynaset)
        rst.MoveFirst
        
        Do Until rst.EOF
            If Not IsNull(rst!Field2) Then Call PrintDoc(rst!Field2, 1)
            rst.MoveNext
        Loop
    The print doc function can be found here

  6. #6
    Ajz1971 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    7
    Hi again Andy,

    I truly appreciate your help, and I’m sure the example you have given will work.

    Buuut! …Sorry to say! I’m kinda a newbie with VBA… I know what it is and am able to alter code “to a point” to suit my needs (kinda like, copy – paste – fiddle around and hey presto it works “or doesn’t work”).

    As for writing the code myself at the moment, I’m not that experienced sorry to say

    So if by any chance you have the time, maybe you could point me in the direction of a working example?

    If not… No probs M8! And thanks again for your time and effort

  7. #7
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    The code above does the jon


    Sent from my iPhone using Tapatalk

  8. #8
    Ajz1971 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    7
    Thanks Andy... did not see aytee111s Post before replying lol!

  9. #9
    Ajz1971 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    7
    Hi aytee111,

    thanks for your input

    I have put the code you have given me together and I get an ERROR on the (If Not IsNull(rst!Field2) when run?

    The query i am running is named POLICES QUERY and the Field/Column in the query is named POLICY LINKS... I have changed the FIELD2 to POLICY LINKS with no luck?

    Any Idea's as to where I'm going wrong?

    Thanks in advance

  10. #10
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Try using rst.fields(2)


    Sent from my iPhone using Tapatalk

  11. #11
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Spaces in names is a big no-no! Remove them all. They require square brackets around them every time: [POLICY LINKS]

Please reply to this thread with any new information or opinions.

Similar Threads

  1. adding word documents and pdf's to a form
    By Firemann25 in forum Access
    Replies: 2
    Last Post: 04-22-2015, 08:44 AM
  2. Replies: 1
    Last Post: 03-22-2014, 04:10 PM
  3. Replies: 1
    Last Post: 11-30-2011, 07:06 PM
  4. Replies: 6
    Last Post: 07-26-2010, 01:53 PM
  5. Categorizing Word documents with Access
    By radagast in forum Access
    Replies: 0
    Last Post: 06-14-2009, 12:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums