Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / June 2007

Tip: Looking for answers? Try searching our database.

Macro to wait ten seconds..?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gojavid - 15 Jun 2007 18:35 GMT
I have some code that maps a network drive using a shell and command
prompt.  In the same code it checks if the command was successful or
not.  The problem is that it takes a second for command prompt to
create the drive and the macro is already passed the check by the time
it actually maps the drive.

The check I use is:

If dir("mapped drive name")="" then
msgbox("Drive mapping was not successful.")
end if

I was hoping that I could have the macro wait a few seconds before it
checks to see if the drive is mapped.  I thought about a loop, but I
didn't want it to continue forever if the drive didn't map.

Any ideas?
Ron de Bruin - 15 Jun 2007 19:39 GMT
Hi Gojavid

Application.Wait (Now + TimeValue("0:00:03"))

See also
http://www.cpearson.com/excel/ShellAndWait.htm

Signature

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm

>I have some code that maps a network drive using a shell and command
> prompt.  In the same code it checks if the command was successful or
[quoted text clipped - 13 lines]
>
> Any ideas?
Earl Kiosterud - 15 Jun 2007 20:00 GMT
Gojavid,

The problem with a timeout is that you don't know how long to wait, unless you make it long
enough for worst-case situations, and then it takes longer to run than it ought to.  Try
this psuedo-code:

Get start time (StartTzime = Now() )
Test for drive (If dir("mapped drive name")<>"")
 No,
   Been too long? (test current time against StartTime)
     Yes, get out, mapping failed
     No,
       Go back and test again (with one-second wait if desired)
 Yes,
   done

Signature

Earl Kiosterud
www.smokeylake.com

   Note: Some folks prefer bottom-posting.
   But if you bottom-post to a reply that's
   already top-posted, the thread gets messy.
   When in Rome...
-----------------------------------------------------------------------

>I have some code that maps a network drive using a shell and command
> prompt.  In the same code it checks if the command was successful or
[quoted text clipped - 13 lines]
>
> Any ideas?
Gojavid - 15 Jun 2007 21:03 GMT
Thank you to both of you!

> Gojavid,
>
[quoted text clipped - 37 lines]
>
> > Any ideas?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.