• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

convert macro to open pdf

Bricklin

New Member
I found the attached macro and Vb that lets me search for and open a xlsm file from with a folder. How would i adapt it to search for and open a .pdf file instead of an excel file?

Many thanks.. I'm slowly learning this stuff.
Code:
Public Function ISWBOPEN(wbName As String) As Boolean
'Originally found written by Jake Marx
    On Error Resume Next
    ISWBOPEN = Len(Workbooks(wbName).Name)
End Function


Sub Open_Saved_Quote()
    Dim WB As Workbook
    Dim strFile As String, sName As String
    ChDrive "C:\Quotes Folder\"
    ChDir "C:\Quotes Folder\"
    strFile = Application.GetOpenFilename(FileFilter:="Excel Files (*.xlsm), *.xlsm", Title:="Please select from a saved quotes file")
    If strFile = "False" Then
        'They pressed Cancel
        MsgBox "Stopping because you did not select a file"
    Else
        sName = Right(strFile, Len(strFile) - InStrRev(strFile, Application.PathSeparator))
        If ISWBOPEN(sName) = True Then
            Set WB = Workbooks(sName)
        Else
            Set WB = Workbooks.Open(strFile)
        End If
    End If
End Sub

Mod Edit: Tag Code
 
Last edited by a moderator:
Back
Top