+ Reply to Thread
Results 1 to 5 of 5

Open "New Database Query" Dialog box thru macro

  1. #1
    Registered User
    Join Date
    04-19-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    2

    Open "New Database Query" Dialog box thru macro

    I want to open the the dialog box provided by menu item Data->Import External Data->"New Database Query" when the xls file is opened. I am doing this in record macro.

    When I retreive the Command Control for "New Database Query" and execute it, I get "Automation Error, Unspecified Error". Is there anything wrong that I am doing here ?
    Following is the code:
    Please Login or Register  to view this content.
    I have also tried an alternate approach to get the control using the following command:
    Please Login or Register  to view this content.
    Here I get the dataMenu as Nothing.

    Is there any way I can open the dialog box for "New Database Query" through a macro.
    Last edited by Kavita Salve; 04-20-2010 at 06:59 AM. Reason: problem solved

  2. #2
    Registered User
    Join Date
    04-15-2010
    Location
    India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 2010 and Excel 2013
    Posts
    22

    Re: Open "New Database Query" Dialog box thru macro

    Hi Kavita,

    Try one of the below codes -

    Please Login or Register  to view this content.
    OR

    Please Login or Register  to view this content.
    Best Regards,
    Tarun Juneja
    Excel-o-ratoR
    Last edited by Excel-o-ratoR; 04-19-2010 at 11:44 AM.

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: Open "New Database Query" Dialog box thru macro

    Good afternoon Kavita Salve and Excel-o-ratoR

    ...and welcome to the forum!!

    However, please note thatneither of your posts comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  4. #4
    Registered User
    Join Date
    04-15-2010
    Location
    India
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 2010 and Excel 2013
    Posts
    22

    Re: Open "New Database Query" Dialog box thru macro

    Thanks for reminding, DominicB. I have made the changes to the code posted by me.

    Best Regards,
    Tarun Juneja
    Excel-o-ratoR

  5. #5
    Registered User
    Join Date
    04-19-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Open "New Database Query" Dialog box thru macro

    Hi Tarun,
    Thanks a lot, code snippet 2 has worked for me. Thanks again.

+ 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