Solved Print Multiple file paths saved in table (1 Viewer)

alvingenius

IT Specialist
Local time
Today, 12:56
Joined
Jul 10, 2016
Messages
169
Hi
For archiving or printing it will be recommended to keep em separate,

and i sent you the code, because i'm not that good in vba and i don't know how to code it to
save a pdf for every user as user name in desktop or any place i choose.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:56
Joined
Oct 29, 2018
Messages
21,449
Hi
For archiving or printing it will be recommended to keep em separate,

and i sent you the code, because i'm not that good in vba and i don't know how to code it to
save a pdf for every user as user name in desktop or any place i choose.
Hi. You're post was breaking up. Did you decide to keep the files separate?
 

alvingenius

IT Specialist
Local time
Today, 12:56
Joined
Jul 10, 2016
Messages
169
Hi. You're post was breaking up. Did you decide to keep the files separate?

since the number of files is too big to extract it as 1 pdf with 2000 pages or printing 2000 pages on time
so the best solution will be output requests for every user separate as 1 pdf named as user name
so at the end i will get 50 PDFs for 50 Users
i think thats the best solution
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:56
Joined
Oct 29, 2018
Messages
21,449
since the number of files is too big to extract it as 1 pdf with 2000 pages or printing 2000 pages on time
so the best solution will be output requests for every user separate as 1 pdf named as user name
so at the end i will get 50 PDFs for 50 Users
i think thats the best solution
I agree. Good luck!
 

alvingenius

IT Specialist
Local time
Today, 12:56
Joined
Jul 10, 2016
Messages
169
Do what? I guess I'm still confused. If you decided to keep the files separate, what else is there to do?

Ooh i think you get me wrong

Separate i mean extracting all files per user as 1 pdf

i told u before, every user might have 20 requests ( let's say it's 20 ) and i have em in Files table as paths , so i want to extract em as 1 pdf having 20 pages ! named as user name !

and this operation looped for every other user

so at the end i will get 50 Pdfs named as user names, and every PDF have 20 Pages!

that's what i mean with separate, i don't mean to keep em separate as 1000 pdf separate!

i Hope you get me now!
 

zeroaccess

Active member
Local time
Today, 05:56
Joined
Jan 30, 2020
Messages
671
So you need an Access Report with its recordsource set to a query that contains the Files table and the Users table.

Add the repeating (many side of one-to-many relationship) fields to the detail section

Format the fields as Hyperlinks

Put the User name or User ID in the Report Header

Open report with a WHERE condition for the User

Send Object to .pdf
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:56
Joined
Oct 29, 2018
Messages
21,449
@theDBguy
any chance you help me completing this code?
I gave the code a try the other day just to see if it will work, and it did. You will get a warning message from Adobe if you try to merge fillable forms, but they'll merge anyway. Otherwise, yes, you should be able to use it in your project. The only thing I don't like about the function is it expects an Array, so you'll have to create one first, which isn't really hard. However, I would have preferred the function to use a ParamArray or a CSV argument instead. Cheers!
 

alvingenius

IT Specialist
Local time
Today, 12:56
Joined
Jul 10, 2016
Messages
169
So you need an Access Report with its recordsource set to a query that contains the Files table and the Users table.

Add the repeating (many side of one-to-many relationship) fields to the detail section

Format the fields as Hyperlinks

Put the User name or User ID in the Report Header

Open report with a WHERE condition for the User

Send Object to .pdf

what i want is :
Capture1.PNG


this query have what i want to extract as pdf /

i wanna click a btn to merge all file paths for every user and save it automatically to Desktop named by username

so the final output in desktop will be
Mike.pdf (2 pages)
Peter.pdf ( 2 Pages )
 

alvingenius

IT Specialist
Local time
Today, 12:56
Joined
Jul 10, 2016
Messages
169
I gave the code a try the other day just to see if it will work, and it did. You will get a warning message from Adobe if you try to merge fillable forms, but they'll merge anyway. Otherwise, yes, you should be able to use it in your project. The only thing I don't like about the function is it expects an Array, so you'll have to create one first, which isn't really hard. However, I would have preferred the function to use a ParamArray or a CSV argument instead. Cheers!

Hi
That's great u made it work
and PDfs is not fillable, its Scanned files
About array .. please explain more as i said i'm not that good in VBA 🙈:(
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:56
Joined
Oct 29, 2018
Messages
21,449
Hi
That's great u made it work
and PDfs is not fillable, its Scanned files
About array .. please explain more as i said i'm not that good in VBA 🙈:(
Probably, the easiest way for you to create the array for that function is by using my SimpleCSV() function to combine all the file names into one string. Then, you can use the Split() function to create the array for the merge PDF function. Hope that helps...
 

alvingenius

IT Specialist
Local time
Today, 12:56
Joined
Jul 10, 2016
Messages
169
Probably, the easiest way for you to create the array for that function is by using my SimpleCSV() function to combine all the file names into one string. Then, you can use the Split() function to create the array for the merge PDF function. Hope that helps...
Hi

I've checked ur SimpleCSV() function , and you teched me something new today. thanks for that (y) (y)

what I learned is Arrays is working like Dim xx as strings or integers, but without sizing
and with your SimpleCSV function, it concatenates all file paths to 1 very big string
and with Split function we can split it with "," so every file path will be separated again

so the final output is :
Capture1.PNG

the result as u can see , 4 file paths ( 2 file paths for every user) - see the table

SQL:
Private Sub Command27_Click()
Dim i As Integer
Dim LinksArray() As String
    LinksArray = Split(SimpleCSV("SELECT Files.xLink FROM Files WHERE Files.fType In('xID','Passport')"), ",")

For i = LBound(LinksArray) To UBound(LinksArray)
    'looping through array here
    Debug.Print LinksArray(i)
Next i
End Sub


Now with the button code to merge pdfs from this link

SQL:
Sub Combine_PDFs_Demo()
Dim strPDFs(0 To 2) As String
Dim bSuccess As Boolean
strPDFs(0) = "C:\Users\Ryan\Desktop\Page1.pdf"
strPDFs(1) = "C:\Users\Ryan\Desktop\Page5.pdf"
strPDFs(2) = "C:\Users\Ryan\Desktop\Page10.pdf"

bSuccess = MergePDFs(strPDFs, "C:\Users\Ryan\Desktop\MyNewPDF.pdf")

If bSuccess = False Then MsgBox "Failed to combine all PDFs", vbCritical, "Failed to Merge PDFs"

End Sub

So what i don't understand now
1- how to edit this code^ to get file paths from LinksArray(i)
2- how to get 1 merged pdf for every user ? the output i expected from this example should be Mike.pdf ( 2pages ) and peter.pdf ( 2 pages )
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:56
Joined
Oct 29, 2018
Messages
21,449
Hi

I've checked ur SimpleCSV() function , and you teched me something new today. thanks for that (y) (y)

what I learned is Arrays is working like Dim xx as strings or integers, but without sizing
and with your SimpleCSV function, it concatenates all file paths to 1 very big string
and with Split function we can split it with "," so every file path will be separated again

so the final output is :
View attachment 81800
the result as u can see , 4 file paths ( 2 file paths for every user) - see the table

SQL:
Private Sub Command27_Click()
Dim i As Integer
Dim LinksArray() As String
    LinksArray = Split(SimpleCSV("SELECT Files.xLink FROM Files WHERE Files.fType In('xID','Passport')"), ",")

For i = LBound(LinksArray) To UBound(LinksArray)
    'looping through array here
    Debug.Print LinksArray(i)
Next i
End Sub


Now with the button code to merge pdfs from this link

SQL:
Sub Combine_PDFs_Demo()
Dim strPDFs(0 To 2) As String
Dim bSuccess As Boolean
strPDFs(0) = "C:\Users\Ryan\Desktop\Page1.pdf"
strPDFs(1) = "C:\Users\Ryan\Desktop\Page5.pdf"
strPDFs(2) = "C:\Users\Ryan\Desktop\Page10.pdf"

bSuccess = MergePDFs(strPDFs, "C:\Users\Ryan\Desktop\MyNewPDF.pdf")

If bSuccess = False Then MsgBox "Failed to combine all PDFs", vbCritical, "Failed to Merge PDFs"

End Sub

So what i don't understand now
1- how to edit this code^ to get file paths from LinksArray(i)
2- how to get 1 merged pdf for every user ? the output i expected from this example should be Mike.pdf ( 2pages ) and peter.pdf ( 2 pages )
So now, you just pass the array to the function when you call it along with the name of the final merged file you want to have in the end. So, it might be something like:

MergePDFs ArrayName(), "C:\FolderName\FileName.pdf"
 

alvingenius

IT Specialist
Local time
Today, 12:56
Joined
Jul 10, 2016
Messages
169
So now, you just pass the array to the function when you call it along with the name of the final merged file you want to have in the end. So, it might be something like:

MergePDFs ArrayName(), "C:\FolderName\FileName.pdf"

Regarding this code

Code:
Sub Combine_PDFs_Demo()
Dim bSuccess As Boolean
Dim strPDFs(0 To 2) As String
strPDFs(0) = "C:\Users\Ryan\Desktop\Page1.pdf"
strPDFs(1) = "C:\Users\Ryan\Desktop\Page5.pdf"
strPDFs(2) = "C:\Users\Ryan\Desktop\Page10.pdf"

bSuccess = MergePDFs(strPDFs, "C:\Users\Ryan\Desktop\MyNewPDF.pdf")

If bSuccess = False Then MsgBox "Failed to combine all PDFs", vbCritical, "Failed to Merge PDFs"

End Sub

i've tried
strPDFs(0) = "C:\Users\Mezo\Desktop\New folder\1.pdf"
strPDFs(0) =LinksArray(1)

and i've got the Fail msgbox

and i've revised the topic
If it fails, it will return False. There are a number of reasons the function could return False, but two of the most common reasons are:

  1. One or more of the PDFs you defined in arrFiles doesn’t exist. If that’s the case, the macro will continue to combine the existing PDF files, but it will skip over the non-existent files (of course).
  2. You don’t have Adobe Acrobat installed on your computer or you haven’t added a reference to the “Adobe Acrobat X.0 Type Library.” It’s important to note that just because you see an Adobe Acrobat X.0 Type Libray in your references, it doesn’t mean you have Acrobat installed. You may just have the Reader installed, in which case the macro won’t work.

and the 2 points is valid on my end

and Still , this code even if it works , it will merge all file paths to only 1 file !!

and that's not the output i want !!

the output i want must be: [Username].pdf as
Mike.pdf ( 2 pages )
Peter.pdf ( 2 pages )
at Desktop

i want to click a button and it get file paths form the table based on every ID , and saves it in desktop on 1 PDF file named by Username equivalent user id

So i think i miss some edits on this code
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 03:56
Joined
Oct 29, 2018
Messages
21,449
Regarding this code

Code:
Sub Combine_PDFs_Demo()
Dim bSuccess As Boolean
Dim strPDFs(0 To 2) As String
strPDFs(0) = "C:\Users\Ryan\Desktop\Page1.pdf"
strPDFs(1) = "C:\Users\Ryan\Desktop\Page5.pdf"
strPDFs(2) = "C:\Users\Ryan\Desktop\Page10.pdf"

bSuccess = MergePDFs(strPDFs, "C:\Users\Ryan\Desktop\MyNewPDF.pdf")

If bSuccess = False Then MsgBox "Failed to combine all PDFs", vbCritical, "Failed to Merge PDFs"

End Sub

i've tried
strPDFs(0) = "C:\Users\Mezo\Desktop\New folder\1.pdf"
strPDFs(0) =LinksArray(1)

and i've got the Fail msgbox

and i've revised the topic
If it fails, it will return False. There are a number of reasons the function could return False, but two of the most common reasons are:

  1. One or more of the PDFs you defined in arrFiles doesn’t exist. If that’s the case, the macro will continue to combine the existing PDF files, but it will skip over the non-existent files (of course).
  2. You don’t have Adobe Acrobat installed on your computer or you haven’t added a reference to the “Adobe Acrobat X.0 Type Library.” It’s important to note that just because you see an Adobe Acrobat X.0 Type Libray in your references, it doesn’t mean you have Acrobat installed. You may just have the Reader installed, in which case the macro won’t work.

and the 2 points is valid on my end

and Still , this code even if it works , it will merge all file paths to only 1 file !!

and that's not the output i want !!

the output i want must be: [Username].pdf as
Mike.pdf ( 2 pages )
Peter.pdf ( 2 pages )
at Desktop

i think i need a different combine pdf code ..
Hi. It all depends on the array you pass to the function. It will merge all the PDFs you pass to it. So, if you don't want all your PDFs merged into one, then only pass the ones you want merged. So, when you loop through your data and use the SimpleCSV() function, make sure it's only passing the necessary PDFs to merge for each client - not the entire table. You should be able to do that by using a Where clause to filter the data to a specific client/record.
 

alvingenius

IT Specialist
Local time
Today, 12:56
Joined
Jul 10, 2016
Messages
169
Hi. It all depends on the array you pass to the function. It will merge all the PDFs you pass to it. So, if you don't want all your PDFs merged into one, then only pass the ones you want merged. So, when you loop through your data and use the SimpleCSV() function, make sure it's only passing the necessary PDFs to merge for each client - not the entire table. You should be able to do that by using a Where clause to filter the data to a specific client/record.

i don't wanna filter data by client ID , i want all file paths in the table to be extracted but the output needed is 1 pdf for every user !

i think i've failed to explain my idea , i will start a new post, since you already fixed the post issue about printing paths in table
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:56
Joined
Oct 29, 2018
Messages
21,449
i don't wanna filter data by client ID , i want all file paths in the table to be extracted but the output needed is 1 pdf for every user !

i think i've failed to explain my idea , i will start a new post, since you already fixed the post issue about printing paths in table
Hi. You "do" want to filter the data - as you merge the PDF. You would only do it within the SimpleCSV() function. Otherwise, you will have the same merged PDFs for every record. For example, let's say you have 3 names with 2 PDFs each, then you want to loop through the 3 names and "filter" the PDFs for each name before merging them. This is the same principle as when we were "printing" the PDFs. We didn't want to print all the files for each name, we only needed to print the ID and photos. So, we "filtered" the data to exclude other PDFs we didn't want printed.
 

alvingenius

IT Specialist
Local time
Today, 12:56
Joined
Jul 10, 2016
Messages
169
Hi. You "do" want to filter the data - as you merge the PDF. You would only do it within the SimpleCSV() function. Otherwise, you will have the same merged PDFs for every record. For example, let's say you have 3 names with 2 PDFs each, then you want to loop through the 3 names and "filter" the PDFs for each name before merging them. This is the same principle as when we were "printing" the PDFs. We didn't want to print all the files for each name, we only needed to print the ID and photos. So, we "filtered" the data to exclude other PDFs we didn't want printed.

That's true
But till this point i've reached i don't know how to continue or do what you telling here in this quote

so here is the equivalent of your simpleCSV() function based on the File Table

SQL:
SimpleCSV("SELECT Files.xLink FROM Files WHERE Files.fType In('xID','Passport')")

If i may ask you to make the edits on sample DB on your reply here and change print code to let it only extract PDFs as 1 merged file per user and file named by username and delete filter by used name !
i need to get all file for all users if i didn't choose a user
 

Users who are viewing this thread

Top Bottom