+ Reply to Thread
Results 1 to 11 of 11

This code is unreliable, Anyone know what I got Wrong?

  1. #1
    Registered User
    Join Date
    11-10-2017
    Location
    Montana
    MS-Off Ver
    2013
    Posts
    5

    Post This code is unreliable, Anyone know what I got Wrong?

    I created A simple spread sheet that requires certain information before allowing submit. Upon submit it Saves a PDF of the spreadsheet, attaches it to an email and sends it to our Helpdesk email, then kills the PDF. Well it was working fine on my PC, I sent it to another collegue to test it out, and it ran everything up to adding the file to the email and failed because it couldn't find the file (though it was saved on the desktop). It works sometimes I use it and it fails sometimes. Anyone have thoughts on what to fix? VBA is not at all my strong point. I have very limited knowledge of it, and most of this code was found in these forums. I need this to work seamlessly, but Not sure how to get there. Thanks for the Help! Please forgive me if I put the Code in the wrong place. (Email address it sends to has been removed FYI)
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by That One Guy; 11-10-2017 at 03:05 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: This code is unreliable, Anyone know what I got Wrong?

    Your attachment is corrupt.

    How is it supposed to end up on the user's desktop, unless that path is in A1?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    11-10-2017
    Location
    Montana
    MS-Off Ver
    2013
    Posts
    5

    Re: This code is unreliable, Anyone know what I got Wrong?

    That is a good question. I suppose it is just going to the default file path right now? If you run it just through the export .PDF, it Puts a PDF on the desktop. At least when I run it. The issue is having it get the file from the desktop, at least when it doesn't work. But pdffile is defined as the PDF that was saved right? So when it preforms .attachments.add PdfFile, it should go get the same PDF it saved, reguardless of the location. I am open to it always saving to the desktop, and Getting the Specified File from the Desktop each time. The issue is there are many users that will be pulling this file from a shared location. So it has to be able to use the Desktop path of the current user for both saving the PDF and getting the file for attachment.

    I will try to add the Spreadsheet again.
    Attached Files Attached Files

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: This code is unreliable, Anyone know what I got Wrong?

    If at all possible, don't use Desktop or it's subfolders.

    In many companies, Desktop can be provisioned through LogonScript or other means (via ActiveDirectoryObject), and may not be same as what is normally considered as Desktop (C:\Users\Username\Desktop).

    I'd recommend using FSO or MkDir to choose/create folder to save the PDF.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: This code is unreliable, Anyone know what I got Wrong?

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-10-2017
    Location
    Montana
    MS-Off Ver
    2013
    Posts
    5

    Re: This code is unreliable, Anyone know what I got Wrong?

    Shg,

    I used your Code for naming the Pdf but still came up with a runtime error at .Attachments.add PdfFile. It says unable to find File
    I am sorry If I am doing something Wrong, I feel like I am a newbie at programming and I jumped into the deep end.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: This code is unreliable, Anyone know what I got Wrong?

    Does the file appear on the desktop?

  8. #8
    Registered User
    Join Date
    11-10-2017
    Location
    Montana
    MS-Off Ver
    2013
    Posts
    5

    Re: This code is unreliable, Anyone know what I got Wrong?

    Yes it does indeed. That is what confuses me the most. It puts the file there, but it can't find what it just created. That is where I am left scratching my head.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: This code is unreliable, Anyone know what I got Wrong?

    What's the filename?

  10. #10
    Registered User
    Join Date
    11-10-2017
    Location
    Montana
    MS-Off Ver
    2013
    Posts
    5

    Re: This code is unreliable, Anyone know what I got Wrong?

    Design Change Requestpdf

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: This code is unreliable, Anyone know what I got Wrong?

    Unrelated to the problem, but it should have a dot in it:

    Please Login or Register  to view this content.
    Put a breakpoint into the code and from the immediate window, after the filename is initialized, enter

    Please Login or Register  to view this content.
    What do you see?

+ 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] Unreliable MATCH formula
    By Solvax in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 05-28-2017, 05:31 PM
  2. changing or removing unreliable data
    By Zydrunas in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-24-2015, 04:51 AM
  3. [SOLVED] I can't find the reason why function gives unreliable results
    By Hein in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 08-21-2013, 02:57 PM
  4. Application.Calculate being unreliable
    By Bishonen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-14-2013, 04:06 AM
  5. Unreliable pivot table
    By amalfaro in forum Excel General
    Replies: 9
    Last Post: 07-16-2012, 10:25 AM
  6. Scrolling in Excel unreliable
    By Peter in forum Excel General
    Replies: 0
    Last Post: 06-20-2006, 09:35 PM
  7. [SOLVED] V Lookup w/ unreliable data
    By hshayh0rn in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-10-2006, 04:55 PM

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