X = SHELL

Hi all is there any difference between this..

Shell ("R:\provaclick.exe") 

and this .. 

X = Shell ("R:\provaclick.exe")

...? tx !
0
Utf
5/16/2010 1:05:01 AM
excel.programming 6508 articles. 2 followers. Follow

5 Replies
1099 Views

Similar Articles

[PageSpeed] 40

If you have no need for the return value of Shell (e.g., detecting
when the Shell'd program terminates), then the two are the same.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
	Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com



On Sat, 15 May 2010 18:05:01 -0700, USH
<USH@discussions.microsoft.com> wrote:

>Hi all is there any difference between this..
>
>Shell ("R:\provaclick.exe") 
>
>and this .. 
>
>X = Shell ("R:\provaclick.exe")
>
>..? tx !
0
Chip
5/16/2010 9:45:58 AM
If assigned to a variable the Shell command runs an executable program and 
returns a Variant (Double) representing the program's task ID if successful, 
otherwise it returns zero. The task ID is a unique number that identifies the 
running program. 

-- 
Jacob (MVP - Excel)


"USH" wrote:

> Hi all is there any difference between this..
> 
> Shell ("R:\provaclick.exe") 
> 
> and this .. 
> 
> X = Shell ("R:\provaclick.exe")
> 
> ..? tx !
0
Utf
5/16/2010 12:39:01 PM
Shell is a function, which means it returns a value. In VB, however, you 
have the ability to call any function as if it were a subroutine... the 
function's value will still be calculated (it gets assigned to a memory 
location consistent in size with the function's declared return value data 
type), it just that the value won't be returned anywhere (the memory 
location eventually gets cleared by VB's "garbage collection" routines 
whether it was assigned anywhere or not). So the quick answer is the two 
statements are the same. HOWEVER, that is only because you used the required 
argument to the Shell function and omitted its optional second argument. IF 
you had specified that optional second argument, your first statement would 
have failed with an error whereas your second statement would still have 
worked correctly. "Why is that?", I am sure you are asking. It has to do 
with how subroutines are called in VB. The proper syntax for calling a 
subroutine in VB are these...

YourSubroutine Argument1, Argument2, etc.

Call YourSubroutine(Argument1, Argument2, etc.)

Notice that the first calling method's syntax does not use parentheses 
whereas the second one's syntax does. Whenever you use parentheses around 
something in VB that is NOT required by syntax, VB treats it as an 
expression to be evaluated. If the expression inside the parentheses is a 
constant or variable reference, then it evaluates to itself. Now, let's 
examine the two possible ways your originally posted first statement could 
have been written...

Without 2nd argument:  Shell ("R:\provaclick.exe")

or

With 2nd argument:     Shell ("R:\provaclick.exe", 2)

where the 2 in the "with 2nd argument" example is the default value for that 
argument when omitted (the 2 is assumed in the first example). Okay, as I 
said, a SINGLE constant (or variable) value inside parentheses evaluates to 
itself, so ("R:\provaclick.exe") gets evaluated to "R:\provaclick.exe" and 
that ends up getting passed to the Shell function. However, in the second 
example, ("R:\provaclick.exe", 2) is not an expression that VB can 
evaluate... there are two terms with a comma instead of an operator between 
them... that is meaningless to VB, so it doesn't know what to pass to the 
Shell function and errors out instead. So, based on this, my advice when 
would be to only use parentheses where they are required by syntax or for 
grouping terms in an expression in order to force the order those terms are 
evaluated in. Your first posted statement does not meet that criteria and, 
so you don't end up scratching your head in the future when you end up 
grouping multiple arguments in a subroutine call, I would recommend against 
using it.

-- 
Rick (MVP - Excel)



"USH" <USH@discussions.microsoft.com> wrote in message 
news:85215E33-03A4-4931-B7FC-75C8A5FF94A9@microsoft.com...
> Hi all is there any difference between this..
>
> Shell ("R:\provaclick.exe")
>
> and this ..
>
> X = Shell ("R:\provaclick.exe")
>
> ..? tx ! 

0
Rick
5/16/2010 2:32:47 PM
If assigned to a variable the executable program returns a Variant (Double) 
representing the program's task ID if successful, otherwise it returns zero. 
The task ID is a unique number that identifies the running program.

-- 
Jacob (MVP - Excel)


"USH" wrote:

> Hi all is there any difference between this..
> 
> Shell ("R:\provaclick.exe") 
> 
> and this .. 
> 
> X = Shell ("R:\provaclick.exe")
> 
> ..? tx !
0
Utf
5/17/2010 4:39:01 AM
thanks all and rick for the useful post
and sorry for the delay but i think the ms forum was stamped !!
paolo



"Jacob Skaria" wrote:

> If assigned to a variable the executable program returns a Variant (Double) 
> representing the program's task ID if successful, otherwise it returns zero. 
> The task ID is a unique number that identifies the running program.
> 
> -- 
> Jacob (MVP - Excel)
> 
> 
> "USH" wrote:
> 
> > Hi all is there any difference between this..
> > 
> > Shell ("R:\provaclick.exe") 
> > 
> > and this .. 
> > 
> > X = Shell ("R:\provaclick.exe")
> > 
> > ..? tx !
0
Utf
5/18/2010 12:53:01 PM
Reply:

Similar Artilces:

User permissions, Office 2001 and OS X 10.2.8
I need help. I am setting up user accounts with OS X 10.2.8. I want to limit what applications people can use. I can find no way to get MS Word, Power Point of Excel into the list of allowabl applications. I select the user, capabilities, check the "use these applications only" but neither drag or locate allow me to put the 2001 applications into the list. All suggestions appreciated. In article <4f9101c40001$ad299f90$a001280a@phx.gbl>, "Terry Booker" <anonymous@discussions.microsoft.com> wrote: > I need help. I am setting up user accounts with OS X >...

Word X Find feature
The Find feature in Word X (with Service Release 1, and up to version 10.1.4 via Microsoft Office v. X 10.1.5 Update) (OS 10.3.4) is driving me mad. With Word 98 the "Find" palette/dialogue box used to float above the document so that you could find whatever it was you wanted, go across to the document to make a change, if necessary, and then click on the "Find Next" button immediately to go on to the next. The "Find What" box would remain unchanged, so you could go straight to the next occurrence of the search object. With Word X, as soon as you edit the docume...

Shortcut Ctrl-X not working on multiple cells
In Excel 97, on some spreadsheets I can't use Ctrl-X to cut multiple cells at once. Other ways to cut work, but Ctrl-X is my preferred method. On other spreadsheets this does work. Has anyone ever seen this before? What happens when you try? Nothing? Error message? Cuts wrong area? Gord Dibben MS Excel MVP On 21 Sep 2006 09:57:16 -0700, "CDM" <mctigrit@yahoo.com> wrote: >In Excel 97, on some spreadsheets I can't use Ctrl-X to cut multiple >cells at once. Other ways to cut work, but Ctrl-X is my preferred >method. On other spreadsheets this does w...

Office:mac v.X #2
Version: v.X Operating System: Mac OS X 10.5 (Leopard) Processor: intel I have subject version of Office. I know that there must be updates to this so I can bring this up to date but I can seem to find the ones I need to start the process. Can someone get me to the beginning? Thanks!!! You can get the Office X 10.1.9 update here: http://snipurl.com/22zx4 On 3/30/08 3:09 PM, in article ee96b4c.-1@webcrossing.caR9absDaxw, "AWOLGolfer@officeformac.com" <AWOLGolfer@officeformac.com> wrote: > Version: v.X > Operating System: Mac OS X 10.5 (Leopard) > Processor: intel &g...

Limitation on point labels in x-y plot.
Some time ago, Ron Peltier, in particular, gave me a lot of assistance on attaching labels to points. However, the method that best suits me for XY ("scatter) charts came from a suggestion by "Andy Pope" <andy@digitab.demon.co.uk> who mentioned Rob Bovey's XY Chart Labeler which is free and down-loadable from: http://www.appspro.com/utilities/utilities.asp Today, trying to label a chart with rather a lot of points, I came across a limitation of Rob's very useful labeller. It seems that the last point index it can handle is 707 in my chart when I wanted 751. I w...

Ho to prevent shell window from showing up?
I use system function call in my program like this: CMyView::Dummy() { //... system("diff file1 file2 > file3"); //... } whenever this method is called, a shell window shows up and disappear very quickly. Is there any way to prevent this shell from showing up? Thanks. Don't use system(). It's a holdover from DOS and 16-bit Windows. Use CreateProcess() instead. "Gordon Li" <gli@salient.com> wrote in message news:Xns93FF64053C7D0GLI@24.24.2.166... > I use system function call in my program like this: > > CMyView::Dummy() > {...

Excel Viewer X W2K
Hi, When i run Excel Viewer in my servers and any others w2k=20 machines the cpu utilization go to 100% almost. Is this a bug or a program error? Please help me because my servers performance have been=20 very poor. Thank=B4s ...

Showing x,y coordinates of a line
Hi, I have a graph of some data points and I was pretty sure that I should be able to run my mouse along the line and wherever I stopped it would show me the x,y coordinates. But instead I just get (series 1, 10) or something as unhelpful as that depending on there I am on the line. I really need this data for a chemistry lab I am doing and I would appreciate any help possible. Thank you. As a retired chemistry prof I cannot think why you would want to do this. I think you need to find the equation of the line and compute y for some given x, or x for some given y. Please tell us more...

Line Chart x
Hi I want have my excel line charts updating automatically when new data is added every quarter. I also want the x – axis display as e.g. 2008Q1 or Q1 dec – 2008. I have at the moment mmm-yyyy, so it is in date formula so it updates automatically, however when a second axis e.g. Q1 is underneath it either won’t allow me to update automatically or there will be a large amount of blank space representing where I have chosen the source data to go to. So is it possible to have two x –axis one date and one text or to have one x – axis displaying date and text on charts that will automaticall...

X-axis labels missing
I have a table showing the number of monthly support center calls by product. Where I used to have a series of months across the x-axis, nothing at all is showing. I compared the current chart to one from two months ago that does display them, but can't see the difference. It's almost as if the axis data was cleared, but I don't see a difference between charts. How can I get it back? Thank you. -- Charlie Randisi What you can try doing is, right click on your chart and go to Source Data. Choose Series. Make sure in the field "Category (X) axis labels" the range...

X axis label help
I have created a line chart with four values from cells in sheet 1, sa A1:D1. Each data point corresponds to a different material. Th material names are in cells in sheet 1, say A2:D2. I select those cell with the material names as my category (X) axis labels. The materia names in the cells have underlining and subscripts, however thi formatting does not appear on the chart. How can I get the underlinin and subscripts to appear as they do in the cells on sheet 1? Thank yo for the help -- Message posted from http://www.ExcelForum.com Hi AFAIK you can't do this as the formulas only link v...

how do I write a formula: if (cell address) is less than X add Y
I am using Excel 2003 and I want to write a formula to add 2 cells with a condition that is the second cell value is less than a preset amount, i.e. $7.50 then add the preset amount instead of the value in the second cell. =a1+MAX(7.5,a2) -- HTH RP (remove nothere from the email address if mailing direct) "CTrophyMan" <CTrophyMan@discussions.microsoft.com> wrote in message news:3485F4E1-F431-4B73-9934-8943C8D10B76@microsoft.com... > I am using Excel 2003 and I want to write a formula to add 2 cells with a > condition that is the second cell value is less than a p...

X Axis, Excel 2007 problem...
I'm sure this is a super simple question. I just started testing some simple charts in 2007. I have a small grid with 4 years and 4 dollar values. (years are 2004, 2005, 2006, 2007). I want to make a simple bar chart with the $ values on the Y axis and the Years on the x axis. The Dollar values and bars display properly but the X axis lists 1, 2, 3, 4 under the bars rather than the years. I can't seem to find the ribbon or menu to change this to display the years. Any help is appreciated. Ever since Excel 1997, there has been this problem. If the x-values are numeric and y...

XY Scatter Chart Not Showing X Axis
I'm trying to create a quadrant analysis. I have the four quadrants as stacked columns and the real data as a XY Scatter. The x axis for the XY Scatter is not showing. The real data series are marked as the secondary axis. Does anyone know how to make the X axis appear? Usually Excel gives you both secondary axes when you add an XY series to a column chart. Go to Chart menu > Options > Axes, and check the box for the secondary X axis. If you're using Excel 2007, it's found on the middle of the three charting tabs, under Axis. - Jon ------- Jon Peltier, Microsoft ...

How can I call shell command from within MFC GUI app?
When I needed call some shell command e.g. copy, I did it by calling "system" function in my console application. How can I do it in my MFC GUI application without that command promt window is displayed? Thanks for advise, Atl. ShellExecute may be want you want. Other option would be to call CreateProcess. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "aladin" <martvar@pobox.sk> wrote in message news:007201c3dab5$ab773d40$a101280a@phx.gbl... | When I needed call some shell command | e.g. copy, I did it by calling "system" function | in my console appli...

Request for help: Fatal problem with Office v.X Updater 10.1.2
Hi there -- I was patching up my copy of Office X. I saw that the 10.1.5 Updater required the 10.1.4 Updater, which in turn requires the 10.1.2 Updater. I downloaded all three. I then quit all Office apps and activated the 10.1.2 Updater. It found my copy of Office and ran just fine. However, when I went to check on the status of my Office folder, I found that a significant number of files were missing. Like, the file for PowerPoint. Furthermore, Word would no longer open. Excel and Entourage seemed fine. I checked the Installer log, which I have attached below. To summarize, there were ...

"Sending Message X of X "
Office OL 2007. I just upgraded to OL2007, and have noticed something strange: When I send a message, the little status bar at the lower right-hand corner that says "Sending Message X of X" says "Sending Message 5 of 5" even if I'm sending only 1 message. It says that if I send 2 messages also. (I haven't tried sending 5 or 6 at a single shot.) My "Sent Items" folder shows only the single message being sent. Makes me queasy....as if I'm sending copies of my email to parts unknown! Any ideas? Thanks. Ken Isaacson SILENT COUNSEL, a legal thrill...

x-y scatter
A friend asked me this question. I don't use x-y scatter in Excel, but it was frustrating to not be able to answer him back. I'm sure it's a simple answer. Does anyone know? Thanks. I have a simple set of data - 20 sets in all. They all have the same x's, different y's (of course). You know how you double-click on a line (x-y scatter) to pull up the line/data properties, right? Where you can adjust the symbol and line type, etc... You can also adjust the order in which they are seen in the legend. After putting 14 sets on one graph, the rest cannot be re-arranged allon...

How to do cells(x,y) for merged field
I have huge problem I cant get data from merged cell it is 4-5,9 in excell when i try to point CELLS(4,9) it returns null cells(5,9) return null as well how can i get this data I cant change the .xls file I cannot reproduce your problem. You do understand that the order of arguments in Cells() is row, column? I merged cells I4:I5 and filled the meged cell with "Eureka!" and ran the following macro Sub tryit() For i = 4 To 5 Cells(i, 1) = Range("I" & i).Value Cells(i, 2) = Cells(i, 9).Value Next i End Sub which put "Eureka!" ...

Axis scale on X-Y scatter graph
Is it possible to link the scales for the X and Y axis so that the scale can increase/decrease automatically, but both X and Y always cover the same range. I am plotting data which is just easier to read if 0,0 remains in the centre of the graph - I could fix the axis scale, but I want to leave as 'auto' due to the changing data. Thanks, Andy On Wed, 7 Feb 2007, in microsoft.public.excel.charting, Andy <Andy@discussions.microsoft.com> said: >Is it possible to link the scales for the X and Y axis so that the scale can >increase/decrease automatically, but both X and Y...

Change of Y- into X-axis
Hi, Can someone please give me directions how to exchange y-axis and x-axis in a line graph (value and category axis)? Thanks Jan Jan - By definition, Excel only allows the category axis to be the horizontal axis in a Line chart. You could create a Scatter chart and switch the X and Y, using some dummy values for the vertical values, and then use a dummy series to provide labels on the vertical axis. Here's some instructions from my web site: http://www.geocities.com/jonpeltier/Excel/Charts/axes.html#VertCatAxis - Jon ------- Jon Peltier, Microsoft Excel MVP http://www.geo...

Red X in White Box Where Picture Should Be
Hello, I have Outlook 2007 and Windows XP. Someone sent me an email that is supposed to have a graphic or a picture in it. All I see is a little blank white box with a little red x in it. Is there any way I can change the encoding (or whatever else I might need to do) in order to be able to see the picture? It appears that the sender did use html code and not plain text when composing and sending the email. Thanks in advance for any help that anyone may be able to give. Candy You may want to take a look at the following link: http://www.microsoft.com/windows/ie/community/column...

complete a line in the middle of a graph to meet both X and Y axes
I have created a line chart with limited data and now want to execute that line in order that they intersect both x and y axes, on the same path.. How can i perform this in Microsoft Excel ...

4.25" X 5.5" Booklet in Publisher
I am trying to create a booklet in Publisher that each page will be 4.25" X 5.5", so I can print 4 'pages' on one sheet of regular paper. I would like the program to shift everything if I need to insert a page, and keep them in order. Page setup, booklet, type 5.5 height, 4.25 width, portrait. Publisher should say, prints two to the pages per sheet. You have the option to insert a page anywhere you want. Publisher will prompt you to insert 4 pages, ignore it and insert one. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.mic...

Modifing the X-Report
I have been trying to modify the contents of the X-Report. RMS should be using the XReport.xml file, but no matter what I do to this file it still doesn't print out my changes. I even ran a Z-Report to clear out the register values. Does anyone know I am doing wrong or am I changing the wrong .xml file. you must re-set the receipt template in the manager. "Moe" <maurice.grafe@direcway.com> wrote in message news:1105408046.545318.193000@c13g2000cwb.googlegroups.com... > I have been trying to modify the contents of the X-Report. > RMS should be using the XReport.xm...