PDA

View Full Version : Run-Time Error 53 File not found



kwesmc
04-01-2018, 10:58 AM
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

Bob Phillips
04-02-2018, 09:59 AM
Check that fPath contains the correct file path.

kwesmc
04-02-2018, 12:55 PM
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"