+ Reply to Thread
Results 1 to 14 of 14

PDF attaches with one file name, but not another

  1. #1
    Registered User
    Join Date
    06-18-2005
    Posts
    24

    PDF attaches with one file name, but not another

    I’m stuck. I’ve got this VBA script that will save worksheet to pdf, then attach it to a newly created draft email via Mac Script. Everything works as intended IF the pdf file named in the 'pdfFileName = "Carl.pdf" line. If I change the file name to 'pdfFileName = "Dave.pdf" (or any other name) I get an invalid procedure error. In both cases, the pdf is correctly saved in the correct path, just “carl” will attach the file & “dave” will not. So, I know the files both exist where they should, so they should both work. I’ve tried a ton of variations and have been trying suggestion from AI. Any insight would be appreciated. I’ve attached a truncated version if the VBA & Apple Script. Thanks in advance

    Please Login or Register  to view this content.
    Last edited by 6StringJazzer; 03-03-2025 at 12:34 PM. Reason: removed excess line breaks from code

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,791

    Re: PDF attaches with one file name, but not another

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not told us about this. You are required to do so. Cross-posts are allowed but you must provide a link to your posts on other sites.
    For new members: you will not be able to post a full URL, so remove the https://www. section and add one or two breaks to the rest of the address. A Moderator or Admin will then fix the link for you.

    Please see Forum Rule #7 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important: https://excelguru.ca/a-message-to-forum-cross-posters/

    (Note: this requirement is not optional. No help to be offered until you provide a link or, for members with fewer than 10 posts, a comment telling us where else you have posted this query.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    06-18-2005
    Posts
    24

    Re: PDF attaches with one file name, but not another

    Sorry about that. I posted this same thing on the Microsoft Community forum & on the MrExcel site aside from this one. I've dug pretty deep trying to sort this one out, so I'm just reaching out to the Excel Hive. Hopefully someone has the right advice.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,791

    Re: PDF attaches with one file name, but not another

    While you have told us where, you have not posted the links as requested. Did you read the link provided to understand why we ask for this.

  5. #5
    Registered User
    Join Date
    06-18-2005
    Posts
    24

    Re: PDF attaches with one file name, but not another


  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,023

    Re: PDF attaches with one file name, but not another

    I fixed your code to remove the extra line break after every line of code.

    If you are using Outlook, why are you using AppleScript to manage email creation instead of using what is built into VBA for the purpose? Troubleshooting your approach will require some rather esoteric knowledge.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  7. #7
    Registered User
    Join Date
    06-18-2005
    Posts
    24

    Re: PDF attaches with one file name, but not another

    My understanding is that since I'm on a Mac, Excel won't interface directly with Outlook like it would on PC. So, MacScript and Apple Script have been necessary, but not flawless.

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,023

    Re: PDF attaches with one file name, but not another

    I looked into this and you are correct. MacOS sandboxes its applications so this sort of cross-application communication is blocked. That's too bad since it's such a powerful feature of VBA.

  9. #9
    Forum Expert ByteMarks's Avatar
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,119

    Re: PDF attaches with one file name, but not another

    I don't have a mac, but have you tried using file name rather than file?

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    06-18-2005
    Posts
    24

    Re: PDF attaches with one file name, but not another

    I haven't until now. With that change, even the "Carl" version wouldn't complete correctly, so I changed it back. But the really strange thing is that if pdfFileName = "Carl", then it works perfectly. If pdfFileName = "Dave", it returns an invalid procedure error. Literally only changing the file name causes the error. So to me that says the rest of the script is able to function.

  11. #11
    Forum Expert ByteMarks's Avatar
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,119

    Re: PDF attaches with one file name, but not another

    Is it the same file other than the name?

    You could try saving Carl, then rename it to Dave, and see if it works. You'd need to hardcode the path or update the variable.
    Last edited by ByteMarks; 03-03-2025 at 01:21 PM.

  12. #12
    Registered User
    Join Date
    06-18-2005
    Posts
    24

    Re: PDF attaches with one file name, but not another

    You would think that's a good thing to try, but I've tried that numerous ways & no dice.

  13. #13
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,791

    Re: PDF attaches with one file name, but not another

    @Soundman

    First, let me make it clear that I have no issue with cross posting, so long as it is done correctly. If you feel that you get more experts pointed to your posts, then fine. What we are asking for, however, is the courtesy of knowing about it. Why? Well it's kind of simple really. If you post on several boards, you have several groups of people working on the same issue, without necessarily knowing what the others are doing.

    Ask yourself this: How would you feel if you worked on an answer for an hour, only to find out that fifteen minutes after you started, someone already had a solution they accepted? I'd be willing to bet you'd be a little upset that you'd wasted your time. Putting it simply. It is the courteous thing to do.

  14. #14
    Registered User
    Join Date
    06-18-2005
    Posts
    24

    Re: PDF attaches with one file name, but not another

    Understood & I agree.

+ 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] Data attaches to wrong Axis Label
    By Scotthc in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 09-05-2021, 07:47 AM
  2. Email Button That Attaches & Copies & Paste
    By Gtrtim112 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2018, 05:51 AM
  3. Replies: 0
    Last Post: 10-27-2015, 08:57 AM
  4. I want to creat an auto email when I update an excell sheet that attaches the sheet also
    By MarcusBooth in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-29-2013, 12:02 PM
  5. Need some VBA that attaches an exported module to the active workbook
    By DebbieEdwards in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2013, 10:40 AM
  6. code that attaches document
    By ea223 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-23-2013, 06:05 PM
  7. [SOLVED] Code attaches copy of Excel worksheet to e-mail but needs to have specific Name!
    By Michelle Deigh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-05-2013, 06:44 PM

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