PDA

View Full Version : Solved: syntax: shell



silentsound
06-07-2010, 12:39 PM
Hi all

Just a quickie. How do I use the shell function and set the windowstyle variable to vbNormalFocus? In the vba help section it suggests:

Shell("notepad", 1) but the VB editor doesn't like this

I know you can use Shell pathname:="notepad", windowstyle:=1

but this is not the point. I spent ages trying to get the brackets to work! Does anyone know why this syntax doesn't work/ what the correct syntax is?

All help much appreciated

cheers
silentsound

Bob Phillips
06-07-2010, 12:48 PM
Dim x

x = Shell("notepad", 1)

mdmackillop
06-07-2010, 12:50 PM
Just lose the brackets.

silentsound
06-07-2010, 01:03 PM
Dim x

x = Shell("notepad", 1)


Ah cheers. that explains the error messages!

silentsound
06-14-2010, 12:26 PM
Further to this, it seems to me that the simplest way to use this command would be to write directly to the command prompt instead of writing to a text file then referencing this later. (correct me if I am wrong btw) Therefore, other than rewriting the command each time is there a way to generate a line break within the shell command? I have tried Googling without success.

Shell "blah blah";"blah2 blah2"

instead of

Shell "blah blah"
Shell "blah2 blah2"

So I am basically looking for whatever should replace the semicolon.

Cheers
Silentsound

Crocus Crow
06-15-2010, 02:06 PM
Not sure what you mean. Why do you need a line break? Do you mean the pipe character '|'? Your 2nd method would work, or put the commands in a batch file and call that with Shell.

silentsound
06-15-2010, 02:57 PM
Not sure what you mean. Why do you need a line break? Do you mean the pipe character '|'? Your 2nd method would work, or put the commands in a batch file and call that with Shell.

I mean is there a command that I can use such that I can use the shell command once but enclose within the brackets several lines of ftp commands. So I am asking if there is a syntax that will separate lines.

eg. Shell(host; username; password)

I want to print host, username and password on separate lines in the command prompt. Basically I was trying to figure out if there is a way to use ftp without a batch file by printing variables straight to the command prompt