+ Reply to Thread
Results 1 to 4 of 4

Batch file to run excel macro

Hybrid View

  1. #1
    Registered User
    Join Date
    08-29-2013
    Location
    brooklyn
    MS-Off Ver
    Excel 2003
    Posts
    11

    Cool Batch file to run excel macro

    how do i excecute a refresh macro in excel by using a batch file, instead of opening the excel file i would just click the .bat from my desktop and it should open the excel spreadsheet and run the refresh macro automatically then close the excel sheet

  2. #2
    Forum Contributor
    Join Date
    01-17-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: Batch file to run excel macro

    In BAT
    start Excel.exe "C\yourfilename.xlsm"
    In Excel (under ThisWorkbook)
    Private Sub Workbook_Open()
    'your code to do what it needs to referesh
    ...
    Application.DisplayAlerts = False
    activeworkbook.Close
    Application.DisplayAlerts = True
    End Sub
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Application.DisplayAlerts = False
    ActiveWorkbook.Save
    Application.DisplayAlerts = True
    End Sub
    If solved remember to mark Thread as solved , to mark your thread as Solved select Thread Tools and click Mark thread as Solved.

    I can't read the mind of my wife so then I get picture but no sound .... and then I mostly get the idea, same goes here picture your outcome and I get the idea.

  3. #3
    Registered User
    Join Date
    08-29-2013
    Location
    brooklyn
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Batch file to run excel macro

    Thanks however my refresh macro accesses a form which runs sql codes and updates the pivot tables on the worksheets. So if I put this code in the THisworkbook section it will not work because not everyone had db access. This batch is just for a few employees I don't want the batch to execute each time the workbook opens, I only want it execute when the refreshALL macro is called. Can yu assist

  4. #4
    Registered User
    Join Date
    08-29-2013
    Location
    brooklyn
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Batch file to run excel macro

    Anyone knows how to access a macro from a batch file and make it to where , only the person running the batch can access the macro, otherwise the speadsheet can viewed without triggering the macro to run when they open the spreadsheet. I am using excel. 2010

+ 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. run an excel macro from a batch file
    By Mobho9 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-15-2012, 10:31 AM
  2. Run excel macro from batch file. Workbook Open
    By Jonsby in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-26-2009, 08:14 AM
  3. [SOLVED] Call a batch file from an Excel Macro
    By Alex Horan in forum Excel General
    Replies: 0
    Last Post: 03-02-2006, 11:35 AM
  4. RE: Call a batch file from an Excel Macro
    By Gary''s Student in forum Excel General
    Replies: 0
    Last Post: 03-02-2006, 11:30 AM
  5. Run Excel Macro through Batch file
    By LJi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-03-2005, 02: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