+ Reply to Thread
Results 1 to 4 of 4

Saving to chosen location then attaching to email

  1. #1
    Registered User
    Join Date
    11-09-2016
    Location
    UK
    MS-Off Ver
    365
    Posts
    85

    Saving to chosen location then attaching to email

    Hi all

    I have a workbook which will be used by people from a number of different clients. I have VBA code to "submit" the completed workbook which involves saving the xlsm file to an xlsx file, enabling the user to choose a save location and then attaching the saved xlsx file to an email.

    I'm quite new to VBA and found this code online which works great if the user wants to save to their desktop but if they choose a folder, the code just exits. Please can you help me modify the code?

    Thanks

    ##other code ensuring mandatory fields have been completed....then

    Please Login or Register  to view this content.
    UPDATE - it works fine when saving to desktop, but choosing any other folder results in the code exiting and no further action
    Last edited by Maleficent; 03-12-2020 at 11:09 AM. Reason: Clarification

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Saving to chosen location then attaching to email

    Hi M,

    I never save anything to the Desktop, so I can't comment on that.

    However, as you probably have already figured out you need to change the following line:
    Please Login or Register  to view this content.
    Your code is difficult to debug because you have a concatenation on your 'save as' line.
    If you had an intermediate step such as:
    Please Login or Register  to view this content.
    you would probably find it easier to verify that you did things correctly using a MsgBox or Debug.Print or single stepping through the debugger.

    Debugger Secrets:
    a. Press 'F8' to single step (goes into subroutines and functions).
    b. Press SHIFT 'F8' to single step OVER subroutines and functions.
    c. Press CTRL 'F8' to stop at the line where the cursor is.
    d. 'Left Click' the margin to the left of a line to set (or clear) a BREAKPOINT.
    e. Press CTRL 'G' to open the IMMEDIATE WINDOW. 'debug.print' statements send their
    output to the IMMEDIATE WINDOW.
    f. Select View > Locals to see all variables while debugging.
    g. To automatically set a BREAKPOINT at a certain location put in the line:
    'Debug.Assert False'
    h. To conditionally set a BREAKPOINT at a certain location put in lines similar to:
    if i >= 20 and xTV20 > 99.56 then
    Debug.Assert False
    endif
    i. A variable value will be displayed by putting the cursor over the variable name.

    To manually set a breakpoint, see http://www.wiseowl.co.uk/blog/s196/breakpoints.htm

    Lewis

  3. #3
    Registered User
    Join Date
    11-09-2016
    Location
    UK
    MS-Off Ver
    365
    Posts
    85

    Re: Saving to chosen location then attaching to email

    Hi LJMetzger

    i did manage to solve my issue but wanted to thank you for taking the time to respond as you have given me some really helpful advice!

    Thanks
    Dani

  4. #4
    Registered User
    Join Date
    11-09-2016
    Location
    UK
    MS-Off Ver
    365
    Posts
    85

    Re: Saving to chosen location then attaching to email

    For anyone else with the same issue, this is how i solved it:

    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. VBA to select SharePoint Content Type when saving Excel file to SharePoint
    By Luffk73 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-24-2017, 05:22 PM
  2. Saving an excel file to sharepoint
    By ctguards1987 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-04-2017, 09:39 AM
  3. Saving to Sharepoint
    By cooper72 in forum Excel General
    Replies: 2
    Last Post: 05-12-2014, 12:42 PM
  4. Saving to Sharepoint
    By cooper72 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-12-2014, 09:28 AM
  5. Help with Saving Excel to SharePoint Folder
    By Inez15 in forum Excel General
    Replies: 6
    Last Post: 03-08-2013, 06:59 PM
  6. saving to sharepoint using macro
    By smakatura in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-28-2011, 11:07 AM
  7. [SOLVED] Problems with saving to Sharepoint
    By jon in forum Excel General
    Replies: 1
    Last Post: 01-09-2006, 05:45 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