+ Reply to Thread
Results 1 to 3 of 3

Save ODC files using VBA

  1. #1
    Registered User
    Join Date
    09-01-2010
    Location
    San Juan, PR
    MS-Off Ver
    Excel 365
    Posts
    3

    Save ODC files using VBA

    Greetings, all. First timer.

    Note: this was originally posted on the MrExcel forum (unable to post link as newbie), but no responses have been received in one week.

    I'm running models in Excel for MS365 which use from 5 to 15 Power Query queries from both external sources and from in-worksheet tables.

    Due to the nature of the data sources, each month I have to do fine-tuning of the queries, so a query named [proKPI_Owners] last month is not the necessarily the same as [proKPI_Owners] this month.

    After I finish editing the queries, I got through all the queries, right-click and select {Export Connection File} to backup. Works perfectly.

    The challenge:
    I would like to set up a VBA subroutine to:
    1. cycle through all the workbook's connections,
    2. edit the connection name with a current-date suffix (Query - proKPI_Owners 2022-06-14), and
    3. save the updated connection file as ODC.

    My current effort is as follows:
    Please Login or Register  to view this content.
    The subroutine cycles as expected through all the queries, retrieves the needed query parameters, and generates the expected new ODC filename.

    My problem is the SaveAsODC command in line 70: when it runs for any of the queries, I get "Conn. #1 | Error # 438 was generated at Line: 70"

    I've searched through MS documentation and as many forums as I can find, and cannot find any example of the correct use of this command to programmatically save ODC files.

    I would greatly appreciate any assistance.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Save ODC files using VBA

    Guessing, based on the fact error 438 is 'Object does not support this property or method' (or words to that effect).
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-01-2010
    Location
    San Juan, PR
    MS-Off Ver
    Excel 365
    Posts
    3

    Re: Save ODC files using VBA

    Sorry for the delay cytop, and many thanks.

    Your suggestions put me in the trail of the final solution: line 70 should be [ .OLEDBConnection.SaveAsODC newSrcConnFN ( no reference to the path)

    This formulation worked. Thanks for your help.

+ 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 code to save files in MAC Excel without Save dialog Box
    By Usha Srivalli in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-09-2021, 08:43 AM
  2. Named Parameter error (Trying to batch save as xlsx files as xml data files)
    By dzheng.328 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-13-2019, 03:22 PM
  3. Replies: 0
    Last Post: 09-09-2014, 05:21 PM
  4. Replies: 2
    Last Post: 08-18-2014, 08:39 PM
  5. Macro to open multiple files, remove header and save multiple files in a new format
    By twocircles in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-17-2014, 05:24 PM
  6. [SOLVED] Save/Closed only macro related files and leave unrelated files open in excel?
    By rdowney79 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-12-2013, 04:17 PM
  7. Replies: 2
    Last Post: 11-30-2005, 01:55 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