Using a variable string in a shell command

mtheriault2000

Well-known Member
Joined
Oct 23, 2008
Messages
826
Hello

I'm trying to use a variable that hold a string in Shell string command. This shell is the command to take a snap picture over a given region and store the picture to a pre determined file name

***The code do compile***

The string variable is : StringAddress = "g:\testsnap\asnap1.jpg"

The following shell command will work

RetVal = Shell(("C:\Program Files (x86)\HyperSnap 7\HprSnap7.exe " & " -hidden -snap:x3602:y155:w1432:h830 -save:jpg g:\testsnap\asnap1.jpg"))

This one, with the stringaddress variable, wont work

RetVal = Shell("C:\Program Files (x86)\HyperSnap 7\HprSnap7.exe " & " -hidden -snap:x3602:y155:w1432:h830 -save:jpg " & StringAddress)

I'm loss. Any help appreciated

Martin
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I would think that you swapped in the variable correctly.

If it would not work, does this work?

Code:
RetVal = Shell(("C:\Program Files (x86)\HyperSnap 7\HprSnap7.exe " & " -hidden -snap:x3602:y155:w1432:h830 -save:jpg """ & StringAddress & """"))
 
Upvote 0

Forum statistics

Threads
1,215,639
Messages
6,125,967
Members
449,276
Latest member
surendra75

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top