+ Reply to Thread
Results 1 to 11 of 11

vba to save document to specific file path

  1. #1
    Forum Contributor
    Join Date
    12-06-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    139

    vba to save document to specific file path

    All

    I would like to change the following code I have 'borrowed' and am stuck as how to go about it...

    The below code is a section where I am asked to enter the file path to save a document.... I want to miss this step and save the document to a specific file path "G:\Sharon\Data_Integrity"

    I have not used the DestFolder before so am unsure as to how to change this...

    any thoughts muchly appreciated

    rgds

    Sharon


    Please Login or Register  to view this content.

  2. #2
    Administrator JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: vba to save document to specific file path

    Something like:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    12-06-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: vba to save document to specific file path

    Thanks JBeaucaire

    ... oopps...

    forgot to include a subsequent section of code referring to DestFolder

    Sharon







    Please Login or Register  to view this content.

  4. #4
    Administrator JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: vba to save document to specific file path

    In my example you can replace fPATH with DestFolder if that's your preferred syntax. Then the rest of your code will work the same.

  5. #5
    Forum Contributor
    Join Date
    12-06-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: vba to save document to specific file path

    JBeaucairne

    I am so missing something and it has been a while since I did any VBA work (albeit beginner)

    Below is what I have and keeps asking me to name the file in the location


    Please Login or Register  to view this content.

  6. #6
    Administrator JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: vba to save document to specific file path

    In post #1 you properly presented the "portion" of code that controls that popup request for a DestFolder.

    In Post #2 I offered a replacement for that "portion" of code.

    So in your main macro, just remove that whole section you presented to us and replace it with the one line:

    Please Login or Register  to view this content.
    The rest of your macro I presume works fine, so this would "hardcode" that DestFolder into the macro and no more popup, you took it out.

  7. #7
    Forum Contributor
    Join Date
    12-06-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: vba to save document to specific file path

    thanks - understand now....

    the remainder of the code works fine but will test out before closing this thread.

    rgds and thx

    Sharon

  8. #8
    Forum Contributor
    Join Date
    12-06-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: vba to save document to specific file path

    JBeaucaire

    I had this working wonderfully but now doesn't want to play the game.

    I have attached the code that is from

    Philip Treacy
    ' http://www.MyOnlineTrainingHub.com/v...t-with-outlook

    with the DestFolder changed (note changed the file path)

    I added a .Body and then copied the VBA to another Object and then the file wouldn't save....I have 9 worksheets that I need to apply this VBA to and have changed the Sub aaa() to reflect the different worksheet names....

    It would appear I have done something....... but no idea what

    I would ideally also like CurrentMonth to be whatever is in ("C6") and by adding ActiveSheet.Range("c6")nothing happens

    Any thoughts

    Option Explicit

    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Administrator JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: vba to save document to specific file path

    In post #1 you posted a large section of code, the ENTIRE thing works to present a popup to help store a DestFolder result to be used later.
    That entire section that you posted originally should be removed from your original macro completely. All of it, all the code from WITH to END WITH.

    In post #6 I suggested the single line of code you would put in its place.

    Don't change anything else in your original macro and it will do as you wish.

  10. #10
    Forum Contributor
    Join Date
    12-06-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: vba to save document to specific file path

    thanks JBeaucaire

    ...going get to the end of this....

    I did use your line of code and replaced all the other as suggested....I also changed the OpenPDFAfterCreating to true as I want to view before sending, and I changed the reference for the current month from h6 to c6 - this is all I changed and now I have an error

    'Document not saved. The document may be open, or an error may have been encountered when saving.'

    Document is not open as it doesn't exist yet....

    .... and I don't understand why it worked yesterday and not now...

  11. #11
    Forum Contributor
    Join Date
    12-06-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: vba to save document to specific file path

    thanks JBeaucaire

    I have solved the issue.... thanks for your advice.

    and

    The file wouldn't save as I had a field in the 'report' output that was in 'date format' ... changed this cell to text and all works wonderfully....

    thanks again for your help on this

    shaz0503

+ 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. Save file with specific name and ask user for the path
    By kammariarun in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2013, 05:19 PM
  2. [SOLVED] Save as specific path and name
    By graiggoriz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-25-2013, 06:40 AM
  3. Replies: 0
    Last Post: 01-27-2013, 12:13 PM
  4. [SOLVED] Save As Dialog Box - Default Path and File Name, User Selects Sub Folder from Default Path
    By christenprochaska in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-12-2012, 05:17 PM
  5. [SOLVED] Can you automatically insert a file path in an Excel document?
    By Mimi in forum Excel General
    Replies: 2
    Last Post: 03-21-2006, 08:15 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