Hi all,

Below is a section of VBA that I have written, and basically I would
like to
get rid of the application.wait lines of code and replace these with
code
that checks that the program in question (cmd.exe) is idle before
continuing.
If anybody can offer a suggestion as to how I can do this, or any other

method that would give good results, please let me know,

Private Sub CommandButton1_Click()
Shell ("C:\Windows\system32\cmd.exe")
Application.Wait Now + TimeValue("00:00:03")
SendKeys "net send " & (TextBox1) & " " & (TextBox2) & "{Enter}"
Application.Wait Now + TimeValue("00:00:05")
SendKeys "Exit" & "{Enter}"
Unload Me
End Sub

Many Thanks,
Mark

Re: VB Wait... by Tom

Tom
Wed Dec 13 07:43:11 CST 2006

Why in the world are you using Sendkeys in the first place? Can't you
just construct the command sequence and include it in the Shell? Say,
something like this ...

Private Sub CommandButton1_Click()
Dim sCmd as String
sCmd = "%comspec% /c net send " & (TextBox1) & " " & (TextBox2)
Shell(sCmd)
Unload Me
end sub

Tom Lavedas
=============
http://members.cox.net/tglbatch/wsh/

MarkHear1 wrote:
> Hi all,
>
> Below is a section of VBA that I have written, and basically I would
> like to
> get rid of the application.wait lines of code and replace these with
> code
> that checks that the program in question (cmd.exe) is idle before
> continuing.
> If anybody can offer a suggestion as to how I can do this, or any other
>
> method that would give good results, please let me know,
>
> Private Sub CommandButton1_Click()
> Shell ("C:\Windows\system32\cmd.exe")
> Application.Wait Now + TimeValue("00:00:03")
> SendKeys "net send " & (TextBox1) & " " & (TextBox2) & "{Enter}"
> Application.Wait Now + TimeValue("00:00:05")
> SendKeys "Exit" & "{Enter}"
> Unload Me
> End Sub
>
> Many Thanks,
> Mark


Re: VB Wait... by MarkHear1

MarkHear1
Wed Dec 13 08:35:26 CST 2006

Tom,

the reason i was using sendkeys is that i am a beginner at VB and it's
the only method i was aware of.

I will test you code out - thank you.

Mark

Tom Lavedas wrote:
> Why in the world are you using Sendkeys in the first place? Can't you
> just construct the command sequence and include it in the Shell? Say,
> something like this ...
>
> Private Sub CommandButton1_Click()
> Dim sCmd as String
> sCmd = "%comspec% /c net send " & (TextBox1) & " " & (TextBox2)
> Shell(sCmd)
> Unload Me
> end sub
>
> Tom Lavedas
> =============
> http://members.cox.net/tglbatch/wsh/
>
> MarkHear1 wrote:
> > Hi all,
> >
> > Below is a section of VBA that I have written, and basically I would
> > like to
> > get rid of the application.wait lines of code and replace these with
> > code
> > that checks that the program in question (cmd.exe) is idle before
> > continuing.
> > If anybody can offer a suggestion as to how I can do this, or any other
> >
> > method that would give good results, please let me know,
> >
> > Private Sub CommandButton1_Click()
> > Shell ("C:\Windows\system32\cmd.exe")
> > Application.Wait Now + TimeValue("00:00:03")
> > SendKeys "net send " & (TextBox1) & " " & (TextBox2) & "{Enter}"
> > Application.Wait Now + TimeValue("00:00:05")
> > SendKeys "Exit" & "{Enter}"
> > Unload Me
> > End Sub
> >
> > Many Thanks,
> > Mark


Re: VB Wait... by MarkHear1

MarkHear1
Wed Dec 13 09:05:04 CST 2006

Tom,

I have just tried to use the code you suggest, and was unable to get it
to work.
Could you please explain it to me?

Regards,
Mark

MarkHear1 wrote:
> Tom,
>
> the reason i was using sendkeys is that i am a beginner at VB and it's
> the only method i was aware of.
>
> I will test you code out - thank you.
>
> Mark
>
> Tom Lavedas wrote:
> > Why in the world are you using Sendkeys in the first place? Can't you
> > just construct the command sequence and include it in the Shell? Say,
> > something like this ...
> >
> > Private Sub CommandButton1_Click()
> > Dim sCmd as String
> > sCmd = "%comspec% /c net send " & (TextBox1) & " " & (TextBox2)
> > Shell(sCmd)
> > Unload Me
> > end sub
> >
> > Tom Lavedas
> > =============
> > http://members.cox.net/tglbatch/wsh/
> >
> > MarkHear1 wrote:
> > > Hi all,
> > >
> > > Below is a section of VBA that I have written, and basically I would
> > > like to
> > > get rid of the application.wait lines of code and replace these with
> > > code
> > > that checks that the program in question (cmd.exe) is idle before
> > > continuing.
> > > If anybody can offer a suggestion as to how I can do this, or any other
> > >
> > > method that would give good results, please let me know,
> > >
> > > Private Sub CommandButton1_Click()
> > > Shell ("C:\Windows\system32\cmd.exe")
> > > Application.Wait Now + TimeValue("00:00:03")
> > > SendKeys "net send " & (TextBox1) & " " & (TextBox2) & "{Enter}"
> > > Application.Wait Now + TimeValue("00:00:05")
> > > SendKeys "Exit" & "{Enter}"
> > > Unload Me
> > > End Sub
> > >
> > > Many Thanks,
> > > Mark


Re: VB Wait... by Tom

Tom
Thu Dec 14 14:53:42 CST 2006

Sorry, I didn't realize the environment variable %COMSPEC% would not be
expanded upon execution. If you replace the original sCmd line with
the statement below, it should work ...

sCmd = Environ("comspec") & " /c net send " & (TextBox1) & " " _
& (TextBox2)

Tom Lavedas
=============

MarkHear1 wrote:
> Tom,
>
> I have just tried to use the code you suggest, and was unable to get it
> to work.
> Could you please explain it to me?
>
> Regards,
> Mark
>
> MarkHear1 wrote:
> > Tom,
> >
> > the reason i was using sendkeys is that i am a beginner at VB and it's
> > the only method i was aware of.
> >
> > I will test you code out - thank you.
> >
> > Mark
> >
> > Tom Lavedas wrote:
> > > Why in the world are you using Sendkeys in the first place? Can't you
> > > just construct the command sequence and include it in the Shell? Say,
> > > something like this ...
> > >
> > > Private Sub CommandButton1_Click()
> > > Dim sCmd as String
> > > sCmd = "%comspec% /c net send " & (TextBox1) & " " & (TextBox2)
> > > Shell(sCmd)
> > > Unload Me
> > > end sub
> > >
> > > Tom Lavedas
> > > =============
> > > http://members.cox.net/tglbatch/wsh/
> > >
> > > MarkHear1 wrote:
> > > > Hi all,
> > > >
> > > > Below is a section of VBA that I have written, and basically I would
> > > > like to
> > > > get rid of the application.wait lines of code and replace these with
> > > > code
> > > > that checks that the program in question (cmd.exe) is idle before
> > > > continuing.
> > > > If anybody can offer a suggestion as to how I can do this, or any other
> > > >
> > > > method that would give good results, please let me know,
> > > >
> > > > Private Sub CommandButton1_Click()
> > > > Shell ("C:\Windows\system32\cmd.exe")
> > > > Application.Wait Now + TimeValue("00:00:03")
> > > > SendKeys "net send " & (TextBox1) & " " & (TextBox2) & "{Enter}"
> > > > Application.Wait Now + TimeValue("00:00:05")
> > > > SendKeys "Exit" & "{Enter}"
> > > > Unload Me
> > > > End Sub
> > > >
> > > > Many Thanks,
> > > > Mark


Re: VB Wait... by MarkHear1

MarkHear1
Fri Dec 15 02:59:22 CST 2006

Tom,

Thank you for this, however in the end i managed to use the following
code -

Dim Cmd As String
Cmd = "C:\Windows\system32\cmd.exe /c net send " & (TextBox1) & " " &
(TextBox2)
Shell (Cmd)

Many thanks,
Mark

Tom Lavedas wrote:
> Sorry, I didn't realize the environment variable %COMSPEC% would not be
> expanded upon execution. If you replace the original sCmd line with
> the statement below, it should work ...
>
> sCmd = Environ("comspec") & " /c net send " & (TextBox1) & " " _
> & (TextBox2)
>
> Tom Lavedas
> =============
>
> MarkHear1 wrote:
> > Tom,
> >
> > I have just tried to use the code you suggest, and was unable to get it
> > to work.
> > Could you please explain it to me?
> >
> > Regards,
> > Mark
> >
> > MarkHear1 wrote:
> > > Tom,
> > >
> > > the reason i was using sendkeys is that i am a beginner at VB and it's
> > > the only method i was aware of.
> > >
> > > I will test you code out - thank you.
> > >
> > > Mark
> > >
> > > Tom Lavedas wrote:
> > > > Why in the world are you using Sendkeys in the first place? Can't you
> > > > just construct the command sequence and include it in the Shell? Say,
> > > > something like this ...
> > > >
> > > > Private Sub CommandButton1_Click()
> > > > Dim sCmd as String
> > > > sCmd = "%comspec% /c net send " & (TextBox1) & " " & (TextBox2)
> > > > Shell(sCmd)
> > > > Unload Me
> > > > end sub
> > > >
> > > > Tom Lavedas
> > > > =============
> > > > http://members.cox.net/tglbatch/wsh/
> > > >
> > > > MarkHear1 wrote:
> > > > > Hi all,
> > > > >
> > > > > Below is a section of VBA that I have written, and basically I would
> > > > > like to
> > > > > get rid of the application.wait lines of code and replace these with
> > > > > code
> > > > > that checks that the program in question (cmd.exe) is idle before
> > > > > continuing.
> > > > > If anybody can offer a suggestion as to how I can do this, or any other
> > > > >
> > > > > method that would give good results, please let me know,
> > > > >
> > > > > Private Sub CommandButton1_Click()
> > > > > Shell ("C:\Windows\system32\cmd.exe")
> > > > > Application.Wait Now + TimeValue("00:00:03")
> > > > > SendKeys "net send " & (TextBox1) & " " & (TextBox2) & "{Enter}"
> > > > > Application.Wait Now + TimeValue("00:00:05")
> > > > > SendKeys "Exit" & "{Enter}"
> > > > > Unload Me
> > > > > End Sub
> > > > >
> > > > > Many Thanks,
> > > > > Mark