
Originally Posted by
rizkifatah
Can we set the range not to specific cells? because if we put specific cell it will be replace for the next file saved.
Sub UploadFile()
Dim DialogBox As FileDialog, sFileLocation As String, sSaveLocation As String
Dim r As Range
'Change your Destination Location Here...
sSaveLocation = "D:\" & "YourFileName" & ".PDF"
Set DialogBox = Application.FileDialog(msoFileDialogOpen)
With DialogBox
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "PDF File", "*.PDF"
.Title = "Select PDF file"
If .Show = -1 Then
sFileLocation = DialogBox.SelectedItems(1)
CreateObject("scripting.filesystemobject").CopyFile sFileLocation, sSaveLocation
'Hyperlink Added Here...
'Change A1 To your desired cell in your coding
For Each r In Range("A1:B15").Cells
ActiveSheet.Hyperlinks.Add Anchor:=r, Address:=sSaveLocation, TextToDisplay:="Click To View"
Next r
MsgBox "File Uploaded Successfully", vbInformation, "Task Completed"
Else
MsgBox "No File Chosen", vbInformation, "File Not Selected"
End If
End With
End Sub
Bookmarks