Minggu, 08 April 2012

Re: [ExcelVBA] Using the Shell function in VBA

 


I think building a .BAT file is the way to go... nand if I remember correctly...which is in doubt :-) ... the start batch command has an R parameter start,r that says hang on untill this BAT file has done. Maybe two BAT files... one with the command in and one with the start in... dunno.

I usually get DOS command syntax by opening a command window and typing the command with a /? switch.

HTH
Lisa

Sent: Sat, Apr 7, 2012 5:47 am
Subject: [ExcelVBA] Using the Shell function in VBA

I have had great success using Excel for Serial/USB I/O using the CreateFile
unction (and related functions) in kernel32, but the functions and low level
outines were written my someone more knowledgable than me. MSDN helped
nderstand them.
I want to try using the Shell function to set the com port up.
I can manually do it in the DOS window using the mode command like this:
:\> mode com4:96,n,8,1
he response is correct. (The port parameters)
However if I use this (used by someone else) in my VBA:
Shell (Environ("comspec") + " /c mode Com4:9600,n,8,2")
There is no error, but it does not change the port parameters. I do see a DOS
indow 'placeholder' thingy momentarily popup in the task bar at the bottom of
he Vista Window.
To verify this I can either change port parameters manually in DOS to
omething like 300 baud and the above doesn't change it back to 9600. Or I can
hange it to 300 baud:
hell (Environ("comspec") + " /c mode Com4:300,n,8,2")
And the port stays at 9600.
I know this isn't exactlly VBA, but there must be a slightly different syntax
or VBA.
Any help here?
FWIW, The references I do have as well as on-line don't give complete syntax for
he DOS mode command either.
Regards, Steve

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar