ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pass cell contents to MSTSC.EXE (Remote Desktop) (https://www.excelbanter.com/excel-programming/374809-pass-cell-contents-mstsc-exe-remote-desktop.html)

Lawrence Miller[_2_]

Pass cell contents to MSTSC.EXE (Remote Desktop)
 
I currenlty have 175 sites of network addresses (1 site per sheet). Each sheet has the IP address I need to connect to in cell B3.

I have a command button that opens Remote Desktop to connect to this address, but I have had to type the address manually into the VBA for each sheet.

I am trying to pass the address value in cell B3 to the VBA for the command button.
(w.x.y.z is the IP address of the target system)

I have tried setting a variable to the contents of cell B3, but can not pass it to mstsc.exe command line

Thnaks in advance for assistance with this

ex:

Private Sub CommandButton1_Click()
Dim RetVal

' Run Remote Desktop.
RetVal = Shell("c:\windows\system32\mstsc.exe /v:w.x.y.z", 1)
End Sub


EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com

Jake Marx[_3_]

Pass cell contents to MSTSC.EXE (Remote Desktop)
 
Hi Lawrence,

To concatenate string values, you use the ampersand (&) character. And to
get the value of a cell, you can use the Value property of the Range object.
Also, you don't need the full path to mstsc, as it is typically in the PATH
environment variable (since it resides in a system folder). This code
should work:

Private Sub CommandButton1_Click()
' Run Remote Desktop.
Shell "mstsc.exe /v:" & Range("B3").Value, 1
End Sub

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]

Lawrence Miller wrote:
I currenlty have 175 sites of network addresses (1 site per sheet).
Each sheet has the IP address I need to connect to in cell B3.

I have a command button that opens Remote Desktop to connect to this
address, but I have had to type the address manually into the VBA for
each sheet.

I am trying to pass the address value in cell B3 to the VBA for the
command button. (w.x.y.z is the IP address of the target system)

I have tried setting a variable to the contents of cell B3, but can
not pass it to mstsc.exe command line

Thnaks in advance for assistance with this

ex:

Private Sub CommandButton1_Click()
Dim RetVal

' Run Remote Desktop.
RetVal = Shell("c:\windows\system32\mstsc.exe /v:w.x.y.z", 1)
End Sub




Lawrence Miller[_2_]

Pass cell contents to MSTSC.EXE (Remote Desktop)
 
This works perfectly!!! I have added 42 more sheets and do not have to edit the VBA code.

(Actually due to the nature of the software load on the other users I share this spreadsheet with, they require the explicit full path in order to get mstsc to work. It works on my system without the full path)



Many, many thanks!

Now to tackle my next task with this......

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com


All times are GMT +1. The time now is 10:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com