• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Run-Time Error 53 File not found |VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Run-Time Error 53 File not found |VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosRun-Time Error 53 File not found
sp_PrintTopic sp_TopicIcon
Run-Time Error 53 File not found
Avatar
Kenneth McMillan
USA
Member
Members

Dashboards

Power Query
Level 0
Forum Posts: 29
Member Since:
November 15, 2017
sp_UserOfflineSmall Offline
1
April 2, 2018 - 10:56 pm
sp_Permalink sp_Print

Hello everyone,

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

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
April 3, 2018 - 3:42 pm
sp_Permalink sp_Print

Hi Kenneth,

Testing this code I also get an error at the same point because the file C:\Users\pgt\AppData\Roaming\Microsoft\Signatures\Default.htm does not exist.

I assume you have triple checked that this file exists on your PC?

When I change the htm sig filename to something that does exist, the error does not occur.

Regards

Phil

Avatar
Kenneth McMillan
USA
Member
Members

Dashboards

Power Query
Level 0
Forum Posts: 29
Member Since:
November 15, 2017
sp_UserOfflineSmall Offline
3
April 4, 2018 - 2:21 am
sp_Permalink sp_Print

Thank you very much Phil!
I will give that a try and let you know.
Thanks again,

Ken Mc

Avatar
Kenneth McMillan
USA
Member
Members

Dashboards

Power Query
Level 0
Forum Posts: 29
Member Since:
November 15, 2017
sp_UserOfflineSmall Offline
4
April 4, 2018 - 7:14 am
sp_Permalink sp_Print

After-display.jpgImage Enlarger

After-Preview.jpgImage Enlarger
Phil,
That worked for me too, but when stepping through code and get to .display, email shows me my image signature and then when the code gets to
.htmlBody = EmailBody & StrSignature and .preview, I get this: See attached.
Would you know why this is happening?

Thanks!

sp_PlupAttachments Attachments
  • sp_PlupImage After-display.jpg (29 KB)
  • sp_PlupImage After-Preview.jpg (29 KB)
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
5
April 4, 2018 - 4:13 pm
sp_Permalink sp_Print sp_EditHistory

Hi Ken,

It would appear that when you read the sig file in, and then add it as part of the HTML body of the email, Outlook is messing up the links to the location of images in the original sig.

Outlook is probably creating a temp file somewhere to hold the HTML contents of your new email, but isn't copying/referencing the images correctly - hence the broken image.

I found that when the image in the sig is stored locally, the image breaks.  If you edit your sig and insert an image that is stored out there on the 'net somewhere, Outlook loads that image correctly.

So you'll need to copy your image onto a web server somewhere, then edit the image link in your sig to point to that.

Cheers

Phil

Avatar
Kenneth McMillan
USA
Member
Members

Dashboards

Power Query
Level 0
Forum Posts: 29
Member Since:
November 15, 2017
sp_UserOfflineSmall Offline
6
April 5, 2018 - 1:57 am
sp_Permalink sp_Print

Thanks Phil.
Looks like more hassle than I want to go through. I suppose I will just go back to a text sig file.

Regards,

Ken Mc

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Richard West, Shanna Henseler, Lawrence Smith, Nada Perovic
Guest(s) 12
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Ray-Yu Yang
George Shihadeh
Naomi Rumble
Uwe von Gostomski
Jonathan Jones
drsven
Forum Stats:
Groups: 3
Forums: 24
Topics: 6212
Posts: 27236

 

Member Stats:
Guest Posters: 49
Members: 31889
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.