+ Reply to Thread
Results 1 to 7 of 7

Excel Code: Email as PDF Error

  1. #1
    Registered User
    Join Date
    01-06-2012
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2010, Excel 365
    Posts
    49

    Excel Code: Email as PDF Error

    I have code that takes an Excel worksheet, converts it to a pdf, creates an email with the pdf attached, then displays the email so the user can add comments and send it.
    It was working fine on my computer last week, but now I get this error:
    Run-time error '-2147024894 (80070002)':
    Cannot find this file. Verify the path and file name are correct.


    Anyone have any idea what's going on or how to fix this?

    Here is my code and I indicated the line that's highlighted when I Debug:
    Please Login or Register  to view this content.

    My work computer: Windows 10 Enterprise / Office 2010
    - Code worked last week, but now won't work
    Co-worker's computer: Windows 7 Pro / Office 2010
    - Code doesn't work
    My test work computer: Windows 7 Pro / Office 2010 - has not been used for months, so hasn't had any recent updates
    - Code doesn't work
    My personal computer: Windows 10 Pro / Office 2016
    - Code works fine

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Excel Code: Email as PDF Error

    Does it error on all your computers now?

    When it errors, what line of code is highlighted when you click the Debug button on the error dialog?

    Have your SN numbers changed? Since the SN is used in the file name, does it contain any invalid characters?

    < (less than)
    > (greater than)
    : (colon)
    " (double quote)
    / (forward slash)
    \ (backslash)
    | (vertical bar or pipe)
    ? (question mark)
    * (asterisk)


    You don't give the PDF file a save path, so it defaults to something? Not sure what path it defaults to. If the user doesn't have admin privileges, some folders are not available.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,369

    Re: Excel Code: Email as PDF Error

    .
    Do Range("AU5").Value and Range("AU3").Value still provide segments of the PATH where the file is located ?

    Is the PDF file STILL LOCATED THERE ?

    If you answer NO to either of those questions, therein lies your error. Even if the PDF file is located in the same location as the EXCEL workbook, EXCEL needs the exact path to the PDF file
    or it cannot attach the file to your email.

  4. #4
    Registered User
    Join Date
    01-06-2012
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2010, Excel 365
    Posts
    49

    Re: Excel Code: Email as PDF Error

    I listed 4 computers that I've tested this on at the bottom of my post - the only one it works on currently is my personal computer.
    I also put a comment within my code as to which line is highlighted when I run the debugger.
    The SNs that I've been testing with are alpha-numeric, no symbols. There are some SNs that include a dash, "-", but that's the only character ever used.

    Yeah, I'm thinking it's a problem with the path. At one point I did try to add a path for it to save to the desktop, but it didn't seem to work. But, I could have written the code wrong.

  5. #5
    Registered User
    Join Date
    01-06-2012
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2010, Excel 365
    Posts
    49

    Re: Excel Code: Email as PDF Error

    No, neither of those include a path. I did try to add a path at one point, but still couldn't get it to work. But, that code could have been wrong.

  6. #6
    Registered User
    Join Date
    01-06-2012
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2010, Excel 365
    Posts
    49

    Re: Excel Code: Email as PDF Error

    Here's the code that I was tinkering with that included the path:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-06-2012
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2010, Excel 365
    Posts
    49

    Re: Excel Code: Email as PDF Error

    I think I actually got it working! After I posted the above code I realized the ".pdf" wasn't in the Filename part of the code. The adjusted code works on my work computer, now to test it on the other computers.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA Code to email multiple people and code to go to the next email if error occurs
    By pmeltzers in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-17-2018, 12:31 PM
  2. [SOLVED] send email using vba with default image signature and a code error
    By gotid in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-11-2018, 10:07 AM
  3. Bad File Name error 52- Code to group email attachments
    By L_Misty in forum Outlook Formatting & Functions
    Replies: 1
    Last Post: 09-06-2017, 07:33 PM
  4. [SOLVED] Error with code to sending email upon save
    By westrs811 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-21-2017, 10:47 AM
  5. [SOLVED] Why do I get this error on code from Mr. Debruin's email code?
    By rkjudy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-14-2014, 05:01 PM
  6. Excel code to email whats in the spreadsheet in the body of email
    By Kain93 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-18-2012, 09:55 AM
  7. Trapping an invalid email error in Excel VBA code
    By Richard Buttrey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-16-2005, 09:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1