2
我已經創建了下面的函數從按鈕打開.PDF在我的winform文件:函數打開.pdf文件沒有打開文件
Function OpenReports(fileName As String) As String
Dim xlWBPath As String
Try
xlWBPath = Globals.ThisWorkbook.Application.ActiveWorkbook.Path
System.Diagnostics.Process.Start(xlWBPath & "\fileName")
Catch ex As Exception
MsgBox("The " & fileName & "is not found on directory")
End Try
Return ""
End Function
當我在這裏調用該函數:
Private Sub btnRptEmployeePayToMarket_Click(sender As Object,
e As EventArgs) Handles btnRptEmployeePayToMarket.Click
OpenReports("Ranges to Market.pdf")
End Sub
它進入錯誤陷阱。它無法找到該文件。但是,如果不是運行該功能,我這樣做私人小組是這樣的:
Private Sub btnRptEmployeePayToMarket_Click(sender As Object, e As EventArgs) Handles btnRptEmployeePayToMarket.Click
Dim xlWBPath As String
Try
xlWBPath = Globals.ThisWorkbook.Application.ActiveWorkbook.Path
System.Diagnostics.Process.Start(xlWBPath & "\Ranges to Market.pdf")
Catch ex As Exception
MsgBox("The file Ranges to Market.pdf is not found on directory")
End Try
End Sub
然後它工作正常。所以我收集它與我的功能有關,但我無法弄清楚它是什麼。
謝謝。就是這樣,我不能相信我錯過了那些顯而易見的事情。 –