Excel - running a cmd line from a cell to cmd/powershell

Motestfilter

New Member
Joined
Aug 6, 2019
Messages
13
Hi,

I have a cell with a command on it and would it be possible to be launched to cmd or powershell? I encountered this function,
Code:
[FONT=monospace]PID = Shell("notepad c:\MyFiles\TextFile.txt", vbNormalFocus)[/FONT]
but I am not sure how would this launch to cmd or powershell. How would I incorporate the cell with the code on it?

Thanks
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
The code must be placed in a code module

1. Try adding a shape (eg rectangle) to your sheet, then ...
2. Right-click on rectangle \ click Assign Macro \ click NEW

3. Window opens up containing ...

Code:
Sub Rectangle1_Click()

End Sub

4. Paste the code into that procedure

Code:
Sub Rectangle1_Click()
[COLOR=#ff0000]    Dim PID
    PID = Shell("notepad.exe C:\MyFiles\TextFile.txt", vbNormalFocus)[/COLOR]
End Sub

5. Go back to Excel with {ALT}{F11}

6. Click on any cell to deselect the shape

7. Click on shape to open the file

If you want it to work differently, then tell us how it should work
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,732
Members
449,093
Latest member
Mnur

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