+ Reply to Thread
Results 1 to 6 of 6

Excel Automation

  1. #1
    Registered User
    Join Date
    06-10-2014
    Posts
    21

    Unable to refresh excel querytables using service

    Hi,

    I am new to the forum and was hoping someone could help me out with my first query.

    I have an excel spreadsheet with a number of querytables in it.

    I have written a service in Visual basic which will open the spreadsheet in the early hours of each morning, cycle through each querytable and refresh it and then save off a copy of the spreadsheet containing the updated info.

    However, when the service executes I get the error 1004 - Application-defined or object-defined error at the line "qt.refresh" (qt being a variable defined as an Excel.QueryTable).

    I have created a separate application that runs as a normal application to test the code and it all works fine when logged in as the user in question. It just doesn't want to play ball when being run as a service when the user is not logged in.

    I found some posts online that suggested removing the "BackgroundQuery:=False", but it still comes up with the same error.

    Do I need to perhaps reference the querytables in a different way? Any help would be appreciated.

    Thanks.
    Last edited by SiriusProjects; 06-10-2014 at 10:06 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Excel Automation

    Is there some sort of security in place on whatever the querytables are querying?
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    06-10-2014
    Posts
    21

    Re: Excel Automation

    The querytables are querying an access database on a network drive but I have ensured that the user (Administrator) profile does have access to this. I am also using UNC Paths.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Excel Automation

    I'm afraid I don't know. What you are attempting is not officially supported (http://support.microsoft.com/kb/257757) although this of course doesn't mean you can't work around it, but it's not something I have ever needed to do. Does task scheduler not meet your needs?

  5. #5
    Registered User
    Join Date
    06-10-2014
    Posts
    21

    Re: Excel Automation

    In typical fashion, shortly after posting on the forum I found the solution. The database I link into, also links to another database and I hadn't converted the network path stored in the first database to a UNC path.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Excel Automation

    Ha - well at least it was a simple fix!

+ 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. [SOLVED] IE Automation using excel vba
    By bknlprasad in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-05-2014, 01:37 AM
  2. excel automation
    By scottich in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-11-2013, 06:21 AM
  3. Excel Automation
    By Patronedheart in forum Excel General
    Replies: 5
    Last Post: 08-06-2009, 12:23 AM
  4. Excel automation
    By Martin Walke in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-28-2006, 10:00 AM
  5. [SOLVED] Excel OLE automation
    By Nicolas in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2005, 03:05 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