ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Adding Hyperlinks to "Archive" (https://www.excelbanter.com/excel-discussion-misc-queries/144217-adding-hyperlinks-archive.html)

[email protected]

Adding Hyperlinks to "Archive"
 
Hi,
I'm working on a workbook with the following functions.

It contains different kinds of form to fill out. When I press
commandbutton 1 I get a "serial" number from a sheet that contains
these and this is inserted in the form,

afterwards I've got a button to save this form as a pdf, to a
specified location and specified filename. The thing i'm stuck with
now is that i want a hyperlink in a sheet called "archive" this link
is goint to be to the previous saved pdf.

The code I'm using at the moment work fine, but when i press the
"save" button again, it writes over the old hyperlink. Så in other
words, i need to add the hyperlinks with some kind of ofset,
so the link will come one by one in a row. My code:

Sub printandsave()
myfilenumber = CStr(ActiveSheet.Range("E2"))
myfilename = "c:\test\SR-" + myfilenumber +
CStr(ActiveSheet.Range("F2")) + ".pdf"

MsgBox (myfilename)

Application.ActivePrinter = "Win2PDF på Ne00:"
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, _
ActivePrinter:="Win2PDF på Ne00:", Collate:=True,
PrToFilename:=myfilename


End Sub

Sub Archive

myfilenumber = CStr(ActiveSheet.Range("E2"))
myfilename = "c:\test\SR-" + myfilenumber +
CStr(ActiveSheet.Range("F2")) + ".pdf"

ActiveSheet.Hyperlinks.Add Anchor:=Worksheets("archive").Range
'somethings missing here("A1"), Address:=myfilename,
TextToDisplay:="SR-" + myfilenumber + CStr(ActiveSheet.Range("F2")) +
".pdf"


'End Sub



All times are GMT +1. The time now is 03:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com