Delay excel startup

G

Gee

Hi all,

I have an excel spreadsheet that starts up from the start-up folder. The
problem is that it starts up before another program does that imports DDE
data into the spreadsheet. This would then cause the spreadsheet to hang. Is
it possible to place a delay statement in the start-up line that would delay
the excel spreadsheet for 5 or 10 seconds.

Thanks for the help.
 
J

Jone Doe

Gee said:
Hi all,

I have an excel spreadsheet that starts up from the start-up folder. The
problem is that it starts up before another program does that imports DDE
data into the spreadsheet. This would then cause the spreadsheet to hang.
Is
it possible to place a delay statement in the start-up line that would
delay
the excel spreadsheet for 5 or 10 seconds.

Thanks for the help.
Try microsoft.public.excel.programming
 
D

DL

You would need to create a batch file, to start the excel file, a delay can
be implimented in the batch file.
Probably a dos ng would assist, I'm a little rusty on batch file syntax
 
T

Torgeir Bakken \(MVP\)

Gee said:
Hi all,

I have an excel spreadsheet that starts up from the start-up folder. The
problem is that it starts up before another program does that imports DDE
data into the spreadsheet. This would then cause the spreadsheet to hang. Is
it possible to place a delay statement in the start-up line that would delay
the excel spreadsheet for 5 or 10 seconds.

Thanks for the help.
Hi,

Put a batch file (.bat or .cmd) or a VBScript file (.vbs) file in the
startup folder, and let it create the pause before launching Excel.
Note that the spreadsheet or a shortcut to the spreadsheet must not
be placed in the startup folder.

Below is both a batch file and a VBScript that will do the job (note
that the batch file will display a console window for 10 seconds, the
VBScript will not).



Batch file:

--------------------8<----------------------
@echo off
:: pause for about 10 seconds
ping.exe -n 11 127.0.0.1

:: launch Excel with specified file
start excel.exe "c:\my data\some.xls"
exit
--------------------8<----------------------


VBScript:

'--------------------8<----------------------

' Spreadsheet to be opened
sFile = "c:\my data\some.xls"

Set oShell = CreateObject("WScript.Shell")

' pause 10 seconds
WScript.Sleep 10 * 1000

' launch Excel with specified file
oShell.Run "excel.exe """ & sFile & """", 1, False

'--------------------8<----------------------
 
G

Gee

Thanks for the answer much appreciated.
Gee

Torgeir Bakken (MVP) said:
Hi,

Put a batch file (.bat or .cmd) or a VBScript file (.vbs) file in the
startup folder, and let it create the pause before launching Excel.
Note that the spreadsheet or a shortcut to the spreadsheet must not
be placed in the startup folder.

Below is both a batch file and a VBScript that will do the job (note
that the batch file will display a console window for 10 seconds, the
VBScript will not).



Batch file:

--------------------8<----------------------
@echo off
:: pause for about 10 seconds
ping.exe -n 11 127.0.0.1

:: launch Excel with specified file
start excel.exe "c:\my data\some.xls"
exit
--------------------8<----------------------


VBScript:

'--------------------8<----------------------

' Spreadsheet to be opened
sFile = "c:\my data\some.xls"

Set oShell = CreateObject("WScript.Shell")

' pause 10 seconds
WScript.Sleep 10 * 1000

' launch Excel with specified file
oShell.Run "excel.exe """ & sFile & """", 1, False

'--------------------8<----------------------


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
 
G

Gee

Thanks Torgeir,

One last question how do I get this spreadsheet to run minimized or in the
background after opening. I want it behind the other program that opens, so
nobody closes it by accident. I'm using the VB script to execute the
spreadsheet.

Thanks Gee
 
T

Torgeir Bakken \(MVP\)

Gee said:
Thanks Torgeir,

One last question how do I get this spreadsheet to run minimized or in the
background after opening. I want it behind the other program that opens, so
nobody closes it by accident. I'm using the VB script to execute the
spreadsheet.
Hi,

oShell.Run "excel.exe """ & sFile & """", 1, False

You could play with the intWindowStyle setting for the Run method in
the line above (the second parameter currently set to 1).

Here is a snippet from the WSH documentation from the documentation
of intWindowStyle (listed under the Run method):


4 Displays a window in its most recent size and position. The active
window remains active.

7 Displays the window as a minimized window. The active window
remains active.

8 Displays the window in its current state. The active window
remains active.



WSH 5.6 documentation (local help file) can be downloaded
from here if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp
 
G

Gee

Thanks works like a dream.



Torgeir Bakken (MVP) said:
Hi,

oShell.Run "excel.exe """ & sFile & """", 1, False

You could play with the intWindowStyle setting for the Run method in
the line above (the second parameter currently set to 1).

Here is a snippet from the WSH documentation from the documentation
of intWindowStyle (listed under the Run method):


4 Displays a window in its most recent size and position. The active
window remains active.

7 Displays the window as a minimized window. The active window
remains active.

8 Displays the window in its current state. The active window
remains active.



WSH 5.6 documentation (local help file) can be downloaded
from here if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top