Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default EXECL.EXE command line

Hi,



I have an xls file that contains a VB macro named LOAD_DATA. The macro loads
some data into xls file.



I need to run LOAD_DATA macro every night through scheduled tasks. Is there
any command line to do that?



I there any better way to run a macro inside an excel file through scheduled
tasks?



Thank you,

Max




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default EXECL.EXE command line

Place your code in the workbook_open routine and just open the file using task manager.
The code will run automatically.

--
Tim Williams
Palo Alto, CA


"Maxwell2006" wrote in message ...
Hi,



I have an xls file that contains a VB macro named LOAD_DATA. The macro loads
some data into xls file.



I need to run LOAD_DATA macro every night through scheduled tasks. Is there
any command line to do that?



I there any better way to run a macro inside an excel file through scheduled
tasks?



Thank you,

Max






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default EXECL.EXE command line

You can't include in the command line a startup macro name. You
can use the Workbook_Open event procedure in the ThisWorkbook
code module to have code execute when the workbook is opened.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Maxwell2006" wrote in message
...
Hi,



I have an xls file that contains a VB macro named LOAD_DATA.
The macro loads some data into xls file.



I need to run LOAD_DATA macro every night through scheduled
tasks. Is there any command line to do that?



I there any better way to run a macro inside an excel file
through scheduled tasks?



Thank you,

Max






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default EXECL.EXE command line

Hi Chip,

Thanks for help.

Is there anyway that my code can distinguish between being open by user or
being open by scheduled task?



Max







"Chip Pearson" wrote in message
...
You can't include in the command line a startup macro name. You can use
the Workbook_Open event procedure in the ThisWorkbook code module to have
code execute when the workbook is opened.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Maxwell2006" wrote in message
...
Hi,



I have an xls file that contains a VB macro named LOAD_DATA. The macro
loads some data into xls file.



I need to run LOAD_DATA macro every night through scheduled tasks. Is
there any command line to do that?



I there any better way to run a macro inside an excel file through
scheduled tasks?



Thank you,

Max








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default EXECL.EXE command line

I don't believe so. I suppose you could check the time and if it
is within a reasonable margin of your scheduled time, you could
assume it was opened by the scheduler, not a user. This would
work well if you open it up late at night when users wouldn't be
using it. But as far as some property of the workbook itself, I
don't think there is anything to help you out.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Maxwell2006" wrote in message
...
Hi Chip,

Thanks for help.

Is there anyway that my code can distinguish between being open
by user or being open by scheduled task?



Max







"Chip Pearson" wrote in message
...
You can't include in the command line a startup macro name.
You can use the Workbook_Open event procedure in the
ThisWorkbook code module to have code execute when the
workbook is opened.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Maxwell2006" wrote in message
...
Hi,



I have an xls file that contains a VB macro named LOAD_DATA.
The macro loads some data into xls file.



I need to run LOAD_DATA macro every night through scheduled
tasks. Is there any command line to do that?



I there any better way to run a macro inside an excel file
through scheduled tasks?



Thank you,

Max












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default EXECL.EXE command line

I have no experience of scheduling Excel tasks; therefore I cannot comment.

If you Start | Run [Schedule] the following:

"C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" /p c:\ "book1.xls"

whe

1. you are overriding the default path to c:\ (specify your location)
2. making Excel to open workbook book1.xls (specify your name) located in c:\

Your code/macro can run automatically if you include it in or call it from
the Workbook_Open event. In this event, you can save the updated workbook at
your desired location using ActiveWorkbook.SaveAs (see help file)

In order to find out how excel was started, you might try in ThisWorkbook
module:

Private Declare Function GetCommandLine Lib "kernel32" Alias
"GetCommandLineA" () As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal
lpString As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As
Any, pSrc As Any, ByVal ByteLen As Long)


Private Function CommandLine() As String
Dim RetCode As Long, RetLength As Long
Dim RetBuffer As String
RetCode = GetCommandLine()
RetLength = lstrlen(RetCode)
If RetLength 0 Then
CommandLine = Space$(RetLength)
CopyMemory ByVal CommandLine, ByVal RetCode, RetLength
Debug.Print CommandLine
End If
End Function


Your immediate window shows:

"C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" /p c:\

Perhaos the /p switch is your key to knowing that Excel is running as a
scheduled task?




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default EXECL.EXE command line

I investigated scheduled tasks:

in Run,

"C:\Documents and Settings\All Users\Start Menu\Programs\Microsoft
Office\Microsoft Office Excel 2003.lnk" book1.xls

in Start-in

c:\

CommandLine gives

"C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" book1.xls


However:

On opening, the Macro security dialogue pops up unless it is set to Low.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Macro from Command line Phil Smith Excel Discussion (Misc queries) 1 July 21st 07 06:35 PM
VBA & Command Line Soze Excel Programming 1 May 1st 06 06:57 AM
Q: command line in OE JIM.H. Excel Discussion (Misc queries) 0 May 30th 05 10:48 PM
argument in command line Mélanie H. Excel Programming 2 April 6th 05 12:40 PM
DOS Command Line Chris Excel Programming 5 October 2nd 03 02:06 PM


All times are GMT +1. The time now is 05:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"