我尝试使用超链接,但它根本没有做任何事情。我想知道我需要更改以使用超链接。
Sub RDB_Worksheet_To_PDF()
Dim FileName As String
Dim PONumber As String
Dim FolderPath As String
PONumber = Sheets("Purchase Order with Sales Tax").Cells(8, 6).Value
FolderPath = "Z:\1.PRODUCTION\1. PURCHASING\PO H 2012\"
If ActiveWindow.SelectedSheets.Count > 1 Then
MsgBox "There is more then one sheet selected," & vbNewLine & _
"be aware that every selected sheet will be published"
End If
'Call the function with the correct arguments
FileName = RDB_Create_PDF(ActiveSheet, FolderPath & PONumber, True, True)
If FileName <> FolderPath & PONumber Then
'Ok, you find the PDF where you saved it
'You can call the mail macro here if you want
MsgBox "Sweet! The PO has been saved as a PDF." & vbNewLine & _
"Click on the PO Number in the PO Number WorkSheet to view."
Else
MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
"Microsoft Add-in is not installed" & vbNewLine & _
"There is no PO number selected" & vbNewLine & _
"The path to Save the file in is not correct" & vbNewLine & _
"You didn't want to overwrite the existing PDF if it exist"
End If
Sheets("PO Number").Select
Range("A1").Select
Set smvar = Cells.Find(What:=PONumber, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
If Not smvar Is Nothing Then smvar.Activate
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
FolderPath & PONumber & ".pdf"
Sheets("Purchase Order with Sales Tax").Select
End Sub
答案 0 :(得分:0)
这对我有用 - 适应。
Sub Tester()
Dim shtPO As Worksheet, smvar As Range
Set shtPO = Sheets("Sheet1")
Set smvar = shtPO.Cells.Find(What:="Hello", _
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart)
If Not smvar Is Nothing Then
shtPO.Hyperlinks.Add Anchor:=smvar, Address:="C:\folder\folder2\file.pdf"
End If
End Sub
无需选择/激活任何内容。
答案 1 :(得分:0)
不确定我是否清楚地理解了这个问题...... 但是,您可以先选择工作表,然后创建超链接......
Sub createHyperLink()
Sheets("Purchase Order with Sales Tax").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, _
Address:="example.pdf", _
ScreenTip:="This is the link file", _
TextToDisplay:="Linked PDF"
End Sub
这将在名为&#34;带销售税的采购订单&#34;
的工作表中的默认选定单元格中创建链接