Software Engineer
asked on
How to Have Macro Files Automatically "Edit"
Hello:
I created a macro for an ERP application that open a couple of windows and runs their processes. In addition, I have configured Windows Task Scheduler to run this macro, automatically.
The only issue is that the ERP windows have dates in them. So, in order to have the macro's .mac file "know" to run those two routines on a certain date, the .mac file has to be edited in Notepad.
Is there any sort of tool that will, somehow, automatically edit a .mac file to change the dates to be the last day of the month?
Thanks!
John
I created a macro for an ERP application that open a couple of windows and runs their processes. In addition, I have configured Windows Task Scheduler to run this macro, automatically.
The only issue is that the ERP windows have dates in them. So, in order to have the macro's .mac file "know" to run those two routines on a certain date, the .mac file has to be edited in Notepad.
Is there any sort of tool that will, somehow, automatically edit a .mac file to change the dates to be the last day of the month?
Thanks!
John
Please post example mac file
you could use a batch like
to pass the last date of the current month as argument to your macro.
you then could use %1 to replace the dates.
Sara
@echo off
set date /t >> today.txt
for /f "delims==/ tokens=1-3" %%n in (today.txt) do (
set /A month=%%n
set /A year=%%p
)
set day=31
set febday=28
set /A leapyear=((%year%/4)*4
if %year%==%leapyear% set febday=29
if %month%==02 set day=%febday%
if %month%==04 set day=30
if %month%==06 set day=30
if %month%==09 set day=30
if %month%==11 set day=30
call your_macro %month%/%day%/%year%
to pass the last date of the current month as argument to your macro.
you then could use %1 to replace the dates.
Sara
ASKER
Thanks, sarabande!
Please, forgive my misunderstanding. But when you mention to use %1 for replacing the dates, do you mean to replace the date syntax in your code with "%1"?
John
Please, forgive my misunderstanding. But when you mention to use %1 for replacing the dates, do you mean to replace the date syntax in your code with "%1"?
John
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.