Hi All
I have the following code that searches a network folder for a PDF doc based on the number in a cell and opens it if one exists:
Sub OpenPDF_3()
Dim strPath As String
Dim strFileName As String
strPath = "\\172.27.154.13\D$\Excel Dashboard\Inventory"
If Right(strPath, 1) <> "" Then
strPath = strPath & ""
End If
strFileName = Worksheets("Home").Range("AW15").Value & " New Store Inventory" & ".pdf"
If Len(Dir(strPath & strFileName)) > 0 Then
ActiveWorkbook.FollowHyperlink strPath & strFileName
Else
MsgBox "There is no Inventory available for this store!", vbExclamation
End If
End Sub
This works great if the pdf is named '333 New Store Inventory', 333 being the number that i enter in cell AW15 before clicking the button that runs this code.
However, if the doc is saved as '0333 New Store Inventory' because we often use 4 digits, it wont open.
How can I ignore any leading zeros and have it open weather its called 333 or 0333.
Probably simple to a vba genius but not a newbie like me.
Thanks in advance.
I have the following code that searches a network folder for a PDF doc based on the number in a cell and opens it if one exists:
Sub OpenPDF_3()
Dim strPath As String
Dim strFileName As String
strPath = "\\172.27.154.13\D$\Excel Dashboard\Inventory"
If Right(strPath, 1) <> "" Then
strPath = strPath & ""
End If
strFileName = Worksheets("Home").Range("AW15").Value & " New Store Inventory" & ".pdf"
If Len(Dir(strPath & strFileName)) > 0 Then
ActiveWorkbook.FollowHyperlink strPath & strFileName
Else
MsgBox "There is no Inventory available for this store!", vbExclamation
End If
End Sub
This works great if the pdf is named '333 New Store Inventory', 333 being the number that i enter in cell AW15 before clicking the button that runs this code.
However, if the doc is saved as '0333 New Store Inventory' because we often use 4 digits, it wont open.
How can I ignore any leading zeros and have it open weather its called 333 or 0333.
Probably simple to a vba genius but not a newbie like me.
Thanks in advance.