Save a copy of a hyperlinked pdf to a different file location (1 Viewer)

hubelea

Registered User.
Local time
Today, 14:08
Joined
Nov 9, 2011
Messages
33
I use an access database (2016) that I developed to track products and submit product label pdfs to various government agencies. I use the database to review the products and develop a subset of products that I am going to submit. After reviewing, I wind up with a form which lists all of the products that need to be submitted. On that form is a field which is a hyperlink to the pdf file location, all it does is open the pdf. I am trying to automate the process to select the hyperlinked pdfs and place a copy of them in a separate folder (this folder location will not change) so that I can upload them to an ftp site.


I will be doing this for several hundred records/hyperlinked fields at a time, all coming from the one final form.

Help? I am not proficient at VBA, although I have successfully used it to develop my database based on examples from forums such as these.
 

Cronk

Registered User.
Local time
Tomorrow, 05:08
Joined
Jul 4, 2013
Messages
2,771
..... On that form is a field which is a hyperlink to the pdf file location, all it does is open the pdf. d it to develop my database based on examples from forums such as these.

Can you clarify as to whether the hyperlink is to the folder only, or do you have hyperlinks to all pdf files?
 

hubelea

Registered User.
Local time
Today, 14:08
Joined
Nov 9, 2011
Messages
33
The hyperlink is to each individual PDF, when you click on it it opens the PDF.
 

Tom_2012

New member
Local time
Today, 22:08
Joined
Apr 8, 2017
Messages
3
On that form is a field which is a hyperlink to the pdf file location, all it does is open the pdf.

How do you get the hyperlink placed? You can usually get from the hyperlink the address of the file through the hyperlink property .Target and then use a Filecopy Hyperlink.target Destination

It depends practically of the type of form (still in Access or exported).

Regards

Tom
 

hubelea

Registered User.
Local time
Today, 14:08
Joined
Nov 9, 2011
Messages
33
The form is still in access. So, not sure what you are asking about how I get the hyperlink....For each item, I've inserted the hyperlinked address into the record for that item, so obviously each hyperlink target is different. One form (in Access) would list all of the records with their hyperlink fields.

Is there code that I would need to use to print the targets for all of the hyperlinks on the form? And would I then print them to a file location (I don't want to actually send them to a printer, I want to save them to one specified file folder on my computer.)
 

Cronk

Registered User.
Local time
Tomorrow, 05:08
Joined
Jul 4, 2013
Messages
2,771
Hyperlink data contains up to four parts that are separated by '#' sign
eg DisplayText#Address#Subaddress#Screentip

To extract the address of the file, you can use the HyperlinkPart function.

The following will cause a copy of the file to be copied to some other destination folder.

Code:
strFileName= HyperlinkPart(rst!YourDataField, acAddress)
filecopy strFilename, YourDestinationAddress

When you say your form "lists all of the products that need to be submitted", is the selection in a multi select combo, or a temporary table or what?
 

hubelea

Registered User.
Local time
Today, 14:08
Joined
Nov 9, 2011
Messages
33
Thank you! The form is a continuous form based on a query, which selects data from several tables based on criteria, and includes the field called LabelHyperlink. This hyperlink field was created in one of my tables as a hyperlink field data type (Access 2016).

Two questions: When I go in to edit the hyperlink (on the form) it doesn't show any # signs, it displays the hyperlink address as this: (there are spaces in folders and file names, which it replaces with %20)

..\Account%20Specific\Kroger\0%2011110%2001834%202%20Kroger%20100pct%20Grape%20Jc%2064oz.pdf

Without seeing any # signs in the address, will the code still apply?

Second question: Based on your input, here's the code I've used; its finding an error with the destination file which points to the file location on my computer?

Private Sub Command62_Click()
strFilename = HyperlinkPart(rst!LabelHyperlink, acAddress)
FileCopy strFilename, C:\Users\Anne\Dropbox\Labels\Hyperlinks
End Sub
 

Cronk

Registered User.
Local time
Tomorrow, 05:08
Joined
Jul 4, 2013
Messages
2,771
You don't see the #'s on the form because that's the way hyperlinks work - you see the display part only.

You can however see the full contents of the hyperlink field by using a query
select YourHyperLinkField & "" from YourTable

If you want to see the hyperlink address on your form, set the data source of the text box to
=HyperlinkPart(YourHyperLinkField, acAddress)

As to debugging your code, add
debug.print strFilename
and see what your are trying to copy.
 

Users who are viewing this thread

Top Bottom