sweetiek08
Programmer
- Feb 27, 2008
- 3
I am trying to run Microsoft Excel macros in a scheduled task on a Windows 2003 server. When I let the scheduled tasks run when I am logged in, they work. However, when I am not logged in, the task starts, but doesn't run (it displays "running" as the status, but nothing happens.) I have read that this can happen when network drives are not accessible, but I map the network drive I need in my VBA code:
Set WshNetwork = CreateObject("WScript.Network")
Set AllDrives = WshNetwork.EnumNetworkDrives()
AlreadyConnected = False
For i = 0 To AllDrives.Count - 1 Step 2
If AllDrives.Item(i) = "Y:" Then AlreadyConnected = True
Next
If AlreadyConnected = "False" Then
WshNetwork.MapNetworkDrive "Y:", "\\myserver\myshare"
End If
Any help is much appreciated!
Thank you for your help!
Set WshNetwork = CreateObject("WScript.Network")
Set AllDrives = WshNetwork.EnumNetworkDrives()
AlreadyConnected = False
For i = 0 To AllDrives.Count - 1 Step 2
If AllDrives.Item(i) = "Y:" Then AlreadyConnected = True
Next
If AlreadyConnected = "False" Then
WshNetwork.MapNetworkDrive "Y:", "\\myserver\myshare"
End If
Any help is much appreciated!
Thank you for your help!