Vba Export report to pdf, include hyperlink TextToDisplay

Trunk77

New member
Local time
Today, 14:08
Joined
Jun 16, 2024
Messages
5
Hello,

I export my reports to pdf.
In the vba I want to insert a hyperlink address but with only the texttodisplay must be visible.
String as exemple:
" Address:='X', TextToDisplay:='Link'"
When exported to pdf, the pdf shows everything except the double brackets: Address:='X', TextToDisplay:='Link'
The link can be selected but I only want that as in the example that "Link" is visible in the report.

Any ideas?

Thank you
 
It's hard to offer any suggestions without seeing what you have. Can you maybe post a screenshots of your report in Design View and also maybe post the code you're using?
 
Hello,

Thx for the reply.
Capture1 is the code.
Capture2 is the output pdf.

Best regards
 

Attachments

  • Capture1.JPG
    Capture1.JPG
    75.6 KB · Views: 49
  • Capture2.JPG
    Capture2.JPG
    54.1 KB · Views: 47
Okay, thanks. For that to work, I think you'll need to have your control set to Rich Text. Can you post a screenshot of your report in design view and show us the property sheet for that control?
 
The Textbox "Opmerking" is set to "Plain text".
 

Attachments

  • Capture3.JPG
    Capture3.JPG
    143.2 KB · Views: 44
I changed to rich text but still not working.
I tried as code:
Comment = "<p>4. Kan een invloed hebben op de berekening van het pensioen (DGHR-SPS-SOCPENR-001)</p>" & _
"<a href='X'>Visit our homepage</a>"
Result in pdf:
4. Kan een invloed hebben op de berekening van het pensioen (DGHR-SPS-SOCPENR-001)Visit our homepage

So the text is correct but in the pdf you can't click the hyperlink.
 

Attachments

  • Capture4.JPG
    Capture4.JPG
    13.5 KB · Views: 44
Did you actually use <a href='X'>? What happens if you use a real address? Or, try using a double quote, just in case.
 
just been experimenting with trying to include a hyperlink in a pdf without success.

My clients get sent emails with a 'click this link to download your invoice' message which is a PITA and I was trying to find a way to automate the download. Think I've solved that using the relatively undocumented URLDownloadToFile api - which is of no help to the OP but I extended the investigation into saving the email as a pdf so I could store the emails in a folder along with the download.

Best I could achieve was generating a .htm file from the email rather than a pdf to preserve the hyperlink.

Saving the htm file as a pdf did not produce a clickable link in the pdf so I suspect using richtext will have the same result.

I did find this link which I believe explains why adding a hyperlink to a pdf is not simple


essentially

Before you start adding hyperlinks, you need to understand something about hyperlinks in PDFs. Many document formats (HTML, Word, Google Docs, etc.) associate a hyperlink with a text string.
PDFs work differently: a hyperlink in a PDF has nothing to do with the underlying text. Instead, a hyperlink in a PDF is a pre-defined clickable area on a page. Think of it as an invisible square box. When a user hovers their cursor over this space, their cursor changes, indicating it’s clickable.

So suggest OP considers outputting the report as an htm file instead (acFormatHTML or perhaps acFormatRTF)

Or maybe invest in adobe apps which will convert the text for you - but looks like a manual process to me

In line with the above quote, one of the steps is

2. Drag a rectangle where you want to create a link. Whether it’s a text box or graphic, this will be the area in which the link is active.

edit - another link that may be of use

 
Last edited:

Users who are viewing this thread

Back
Top Bottom