+ Reply to Thread
Results 1 to 3 of 3

CSV file created from template is not saving to same location as the template.

  1. #1
    Registered User
    Join Date
    04-26-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    3

    CSV file created from template is not saving to same location as the template.

    I have Workbook 'A' (WB 'A'). WB 'A' contains a macro which creates a .csv file containing relevant information from WB 'A'. WB 'A' contains a second macro which is supposed to force the .csv file to save to the same location as WB 'A' is currently saved. The .csv file should save to the same location as WB 'A' regardless of how many times I have changed the location of WB 'A'. However, the .csv file is not saving to the correct location. It always saves to my 'My Documents' folder. I am completely illiterate in these matters. I have posted the macro below and I have tried to follow all forum rules. Any help is greatly appreciated.

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474

    Re: CSV file created from template is not saving to same location as the template.

    It may be best just to hard code the path.

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

    Re: CSV file created from template is not saving to same location as the template.

    I will assume you are running this macro from OUTSIDE the WB you are processing. As such, you need to set a variable to remember that wb as you lose focus when you create a new workbook. That will allow you to easily reference the out-of-focus workbook and all of its properties.

    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!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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