Can i apply a hyperlink without opening the other worksheet

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,726
Office Version
  1. 2007
Platform
  1. Windows
I have a worksheet with the supplied code on a command button.
The user would select cell G3 & click the command button to apply a hyperlink to the invoice of which is a pdf.

So i am working on a different worksheet where once all values have been entered into the relevant cells the user prints off an invoice.
The invoice is saved in a folder & is a pdf.

It is now i wish to apply the hyperlink on that other worksheet for the the invoice that was just saved & printed.

It just saves the user printing the invoice then having to watch the other sheet open, have thehyperlink applied then worksheet closed
To the bring him back to the worksheet he is workin on.

I would basically be,select cell G3 Apply the hyperlink to the pdf & job done.
The messages in the below code like HYPERLINK WAS SUCCESSFULL will be removed to minimise the code.

VBA Code:
Private Sub HyperlinkInvoice_Click()
        Const FILE_PATH As String = "C:\Users\Ian\Desktop\REMOTES ETC\DR\DR COPY INVOICES\"
    If ActiveCell.Column = Columns("G").Column Then
        If Len(Dir(FILE_PATH & ActiveCell.Value & ".pdf")) Then
            ActiveCell.Hyperlinks.Add Anchor:=ActiveCell, Address:=FILE_PATH & ActiveCell.Value & ".pdf"
            With ActiveCell
            .Font.Size = 16
            .Font.Bold = True
            End With
            MsgBox "HYPERLINK WAS SUCCESSFUL.", vbExclamation, "HYPERLINKING THE INVOICE NUMBER"
        Else
            ActiveCell.Hyperlinks.Delete
            MsgBox (FILE_PATH & ActiveCell.Value & ".pdf" & vbNewLine & vbNewLine & "FILE IS NOT IN FOLDER SPECIFIED, PLEASE CHECK PATH IS CORRECT"), vbCritical
        End If
    Else
        MsgBox "PLEASE SELECT AN INVOICE NUMBER.", vbExclamation, "HYPERLINKING THE INVOICE NUMBER"
    End If

End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Not sure I understand your post.

=HYPERLINK()

Is a simple formula to force hyperlinks. As pasting the full text in a cell for a hyperlink, needs a manual "ENTER" at the end of the Formula Bar text to create a hyperlink - this is a problem if you have many rows as takes too long.

In the brackets insert the cell reference for the non hyperlinked text, say in cell A2, if: http://www.yourwebaddress.whatever
 
Upvote 0

Forum statistics

Threads
1,223,719
Messages
6,174,089
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top