+ Reply to Thread
Results 1 to 4 of 4

VBA - Changing Data Source Settings - Excel 2013

  1. #1
    Registered User
    Join Date
    02-20-2015
    Location
    toronto
    MS-Off Ver
    2013
    Posts
    2

    VBA - Changing Data Source Settings - Excel 2013

    Hi Friends,
    I need a write a vba script that changes my excel data source setting, but I can't find the command to review/edit this information at all. I've attached a screenshot of the exact information that I am looking to edit. Does any one have any experience in this?

    I basically need to change it to whatever directory the file is sitting in. The rest of it is easy, I just need to find the commands to edit that directory string. Please help!

    Excel Data Source Settings.png

    Cheers,

    Charlie Liu

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VBA - Changing Data Source Settings - Excel 2013

    ChDir is the command (Function) to change directories. You use it to change the from the current directory to a dofferent one. It does not make any permanent changes to Excel settings. It only makes the other directory the active directory. Your system defaults will remain the same as they were before using the command.
    Please Login or Register  to view this content.
    The directory must exist for it to make the change. If you want to create a new directory then
    Please Login or Register  to view this content.
    Then you can use the ChDir function to change to the new directory.
    Last edited by JLGWhiz; 12-10-2018 at 02:46 PM.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    02-20-2015
    Location
    toronto
    MS-Off Ver
    2013
    Posts
    2

    Re: VBA - Changing Data Source Settings - Excel 2013

    Hey JLGWhiz,
    Thank you so much for helping out. How do I specify which "Data Source Setting" that I am changing though?
    If you see my screenshot, you can see 2 in this case. I need the function to call out the list of sources that I have as well, since I will need to write a loop to change any sources that uses a specifc directory.

    Thanks.

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VBA - Changing Data Source Settings - Excel 2013

    Sorry, I did not look close enough the first time. You are looking for code to change the data source in a query. I don't have any experience in doing queries and would need to do research to get the answer. Maybe someone with more expertise in that area will pick up on the thread and provide you a quick answer. I am pretty sure it is fairly simple, but as I said, it is not an area I am familiar with.
    Regards, JLG

+ 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. Pivot Table Data Source/Field Settings
    By jeetkapadia in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 03-12-2018, 05:50 PM
  2. "Initialization of the Data Source Failed" in excel 2013 when transporting file
    By martijnvanderveldt in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-16-2017, 04:48 AM
  3. EXCEL 2013: Settings up histogram
    By sirmimer in forum Excel General
    Replies: 3
    Last Post: 02-24-2017, 03:13 PM
  4. Replies: 1
    Last Post: 07-06-2016, 06:17 PM
  5. Excel 2013 and Access 2013 as Pivot Table External Data Source
    By Grimnebulin in forum Access Tables & Databases
    Replies: 1
    Last Post: 05-27-2015, 02:13 PM
  6. Replies: 0
    Last Post: 02-24-2014, 11:27 AM
  7. Changing an Excel Data Source
    By negcx in forum Excel General
    Replies: 1
    Last Post: 06-20-2009, 01:05 AM

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