Consulting

Results 1 to 3 of 3

Thread: Run-Time Error 53 File not found

  1. #1
    VBAX Regular
    Joined
    Jul 2017
    Posts
    23
    Location

    Run-Time Error 53 File not found

    Hello,
    I am getting a Run-Time Error 53 File not found when I call my function on this line of code:
    Set TSet = fso.GetFile(fPath).OpenAsTextStream(1, -2)

    Can anyone please help?
    Thank you,
    Ken Mc



    Function GetSignature(fPath As String) As String
        Dim fso As Object
        Dim TSet As Object
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set TSet = fso.GetFile(fPath).OpenAsTextStream(1, -2)
        GetSignature = TSet.readall
        TSet.Close
    End Function
    
    Sub Outlook_Default_Signature_With_Image()
    
        'Do not forget to change the email ID
        'before running this code
        Dim OlApp As Object
        Dim NewMail As Object
        Dim EmailBody As String
        Dim StrSignature As String
        Dim sPath As String
        Dim signImageFolderName As String
        Dim completeFolderPath As String
    
        Set OlApp = CreateObject("Outlook.Application")
        Set NewMail = OlApp.CreateItem(0)
    sPath = Environ("appdata") & "\Microsoft\Signatures\Default.htm"
        ' Here Since we are talking about
        ' the HTML email then we need to
        ' write the Body of the Email in
        ' HTML.
        EmailBody = "Hello Friends !!" & ""
        
        sPath = Environ("appdata") & "\Microsoft\Signatures\Default.htm"
        
        StrSignature = GetSignature(sPath)
    completeFolderPath = Environ("appdata") & "\Microsoft\Signatures\" & signImageFolderName
    
        On Error Resume Next
        With NewMail
            .To = "kwesmc1@verizon.net"
           ' .CC = "anybody.com"
           ' .BCC = "anybodyelse.com"
            .Subject = "Hello"
            ' Important! Before writing the body of your email
            ' you should display the mail
            
            .display
            ' Here at the end of the Email Body
            ' HTML Signature is inserted.
            .htmlBody = EmailBody & StrSignature
            .send
        End With
        On Error GoTo 0
        Set NeMail = Nothing
        Set OlApp = Nothing
    End Sub

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Check that fPath contains the correct file path.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Jul 2017
    Posts
    23
    Location
    Thanks xld
    I still can't resolve the correct fie path. I actually put in the actual path, but I'm still getting the error. What am I doing wrong. Here is what I changed:

    sPath = "C:\Users\Ken\AppData\Roaming\Microsoft\Signatures\Default.htm"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •