LogicalHammer1973
New Member
- Joined
- Apr 21, 2020
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
Hi,
Can someone help, i'm relatively new at VBA coding and have got stuck.
Im trying to add a hyperlink to a PDF file created in the VBA macro to a cell in row F (tried sh.range ("F" & n +1).value = hyperlink etc, but no joy ), I've got the code as follows, but cant seem to workout how to create the hyperlink? I would like to name the hyperlink after the file name created for the PDF.
extract of working code so far:
Sheets("Near Miss").Range("A1:N47").ExportAsFixedFormat Type:=xlTypePDF, filename:= _
"c:\my documents\" & ComboBox1.Value & "_Near Miss_" & Format(Now, "dd_mm_YY_hh_mm") & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Workbooks.Open "C:\Users\mulhalla\Documents\KC Site Near Miss Reports.xlsm"
Set sh = Workbooks("KC Site Near Miss Reports").Sheets("Near-Miss")
n = sh.Range("B" & Application.Rows.Count).End(xlUp).Row
sh.Range("B" & n + 1).Value = Me.ComboBox1.Value
sh.Range("C" & n + 1).Value = Me.TextBox1.Value
sh.Range("D" & n + 1).Value = Me.TextBox2.Value
sh.Range("E" & n + 1).Value = Me.TextBox3.Value
sh.Range("H" & n + 1).Value = "No"
Workbooks("KC Site Near Miss Reports").Close SaveChanges:=True
If anyone can help that would be much appreciated,
PS Sorry if coding isn't great.
Can someone help, i'm relatively new at VBA coding and have got stuck.
Im trying to add a hyperlink to a PDF file created in the VBA macro to a cell in row F (tried sh.range ("F" & n +1).value = hyperlink etc, but no joy ), I've got the code as follows, but cant seem to workout how to create the hyperlink? I would like to name the hyperlink after the file name created for the PDF.
extract of working code so far:
Sheets("Near Miss").Range("A1:N47").ExportAsFixedFormat Type:=xlTypePDF, filename:= _
"c:\my documents\" & ComboBox1.Value & "_Near Miss_" & Format(Now, "dd_mm_YY_hh_mm") & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Workbooks.Open "C:\Users\mulhalla\Documents\KC Site Near Miss Reports.xlsm"
Set sh = Workbooks("KC Site Near Miss Reports").Sheets("Near-Miss")
n = sh.Range("B" & Application.Rows.Count).End(xlUp).Row
sh.Range("B" & n + 1).Value = Me.ComboBox1.Value
sh.Range("C" & n + 1).Value = Me.TextBox1.Value
sh.Range("D" & n + 1).Value = Me.TextBox2.Value
sh.Range("E" & n + 1).Value = Me.TextBox3.Value
sh.Range("H" & n + 1).Value = "No"
Workbooks("KC Site Near Miss Reports").Close SaveChanges:=True
If anyone can help that would be much appreciated,
PS Sorry if coding isn't great.