ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto run Macro when file is replaced daily? (https://www.excelbanter.com/excel-programming/393229-auto-run-macro-when-file-replaced-daily.html)

Tasha

Auto run Macro when file is replaced daily?
 
I have a process in Access that transfers a query to a spreadsheet in Excel
every day, replacing the spreadsheet named "PROCESS.xls" each day. I am
trying to find out if there is a way when a file is opened with a specific
name, such as above "PROCESS.xls" to program the macro DLYPROChdr to run
automatically? I know to do it in the original workbook will work, but if
the workbook is replaced daily, won't it also replace the macro? Or maybe
I've confused myself. I have a macro that builds the headers in the
spreadsheet and formats the columns. I want it, every morning when Access
transfers the spreadsheet to Excel as PROCESS.xls to run that macro
automatically when the file is opened from it's designated folder. Hope
someone can help me... ????? Thanks!!!

[email protected][_2_]

Auto run Macro when file is replaced daily?
 
If you're on XP go to:
Start-Programs-Accessories-System Tools-Scheduled Tasks

From there you can run a program to run on a periodic basis.


That program could be Excel, or it could be VBScript, or a bat script.

For starters see what you can do to put DLYPROChdr in an Excel
Auto_Open() Sub.

If you have no control over PROCESS.xls and can't add a Macro to it
then you have to go down the VBScript road.

In VBScript open PROCESS.xls, add your own module, and call a Macro
that calls DLYPROChdr from there.

The VBScript might look like:

Set objXL=Create("Excel.Application")
objXL.Visible=True
oVBC = ojbwb.VBProject.VBComponents
Set M = oVBC.Import("SomeModule.bas")
objwb.Application.Run "SomeModule.DLYPROChdrCallerYouWriteYourself"

tos the VBA that creates headers and footers and instead open a
template that already has to headers and
footer created.



All times are GMT +1. The time now is 10:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com