Can i apply a hyperlink without opening the other worksheet

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,602
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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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