+ Reply to Thread
Results 1 to 6 of 6

Auto-Run macros failing

  1. #1
    Registered User
    Join Date
    01-14-2008
    Posts
    15

    Auto-Run macros failing

    nb.
    I have also asked this question on a sql server forum in case it is sql server related, but please help if this is an Excel issue.



    I have a script (vb) that I use to open up an excel workbook, when I double click the script it opens the excel workbook and runs the macros which are set to auto-run within it all run Ok.

    Now when I try to run the the same script through sql server using xp_cmdshell, the script runs and opens the workbook (I can see this happening in windows explorer), but the macros within the workbook do not run?
    The last command to run should be to close the workbook, but it doesn't even run the first command (i've checked for the changes that should happen)

    I have enabled the macros in excel (enable all macros),
    also I have checked the box to 'Trust to the VBA project object model',
    also I have set the folder which the xlsm file is in to be a trusted location,
    also I have set the activeX settings to 'Enable all controls'

    Yet the macros only will run when I double click the vb script file myself!

    I am stumped on this and have been stuck on it for days now, can anyone help or suggest where I could get help to resolve this as it needs to be done quickly.

  2. #2
    Registered User
    Join Date
    01-14-2008
    Posts
    15

    Re: Auto-Run macros failing

    Here is the vb script I use to open the workbook:-

    Please Login or Register  to view this content.
    Last edited by DonkeyOte; 03-09-2011 at 06:21 AM. Reason: added tags

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,998

    Re: Auto-Run macros failing

    Have you tried replacing the Auto_Open macro with a Workbook_Open event routine instead? (that should run automatically, without needing to try and run it explicitly)
    Everyone who confuses correlation and causation ends up dead.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Auto-Run macros failing

    Are you using VBA or VBS or some other programming language?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    01-14-2008
    Posts
    15

    Re: Auto-Run macros failing

    Thanks for the replies,
    @romperstomper
    never thougt of that one - cheers, will use that in future.

    @royUK
    it's vbs.


    All working now, found the fault to be with using a local path to the files when running the script on the server would work OK (N:\path\file) , but when firing it up from elsewhere I had to change it to a virtual path to get it to run (\\servername\path\file)

    In my testing I was using local path as I was working on the server itself, but had to change this over to a virtual path once testing externally to the server.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Auto-Run macros failing

    I wouldn't have the error handler in the code until I was sure the code was working.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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