|02 Apr 2012||#1|
| || |
Is it possible to pass arguments to local hyperlinks to .cmd files?
I am facing the following interesting situation.
I have an excel file with many columns. One column contains line numbers (for example 3150).
Source Line Number if(this.getValue()==0) 3150 for(i=0;i<value;i++) 3175 while(true) 3200 ... ...
I was able to set up a hyperlink without any command line arguments for one cell, but then I had to set the value explicitly in the batch file as follows -
cd "%~dp0" notepad++ sourcefile.txt -n3150
|My System Specs|
|02 Apr 2012||#3|
| || |
I could find any information on getting this to work using a hyperlink but I did find a way to do it using some VB code. Took me a little while to get it to work though and it might not be perfect, plus you need to enable macros and remove your hyperlinks.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Column = 3 Then Dim strArg As String Dim RetVal As Integer RetVal = MsgBox("Run Batch", vbYesNo) If RetVal = 6 Then strArg = Target RetVal = Shell("C:\ExcelExperiments\BatchFile.bat" & " " & strArg, 1) End If End If End Sub
To get to the VBA editor you need to add it to the ribbon by going to,
File > Options > Customize the ribbon and on the right select "Main tabs" and Check "Developer".
Next click the Developer tab on the ribbon and click "Visual Basic". If your using Excel 2003 a quick Google should find a way to do this.
When the editor opens you should see Sheet1,2,3 and ThisWorkbook on the left. Double click a Sheet to open it and then paste my code into it.
Changing the code.
To change the column change Target.Column = 3 to the column number you need, eg. A=1, B=2 etc...
Removing the prompt may prove a problem when entering new data or accidently clicking in the column but if you want to try it then remove the following lines,
1. RetVal = MsgBox("Run Batch", vbYesNo)
2. If RetVal = 6 Then
3. End If ---- Either one
Instead of automatically running you can run it either via a keyboard shortcut or a button.
I really don't know how much you know about this stuff but if you want to set it up as Macro to use a keyboard shortcut or a button and need help or if there's any other problems with this then let me know.
|My System Specs|
|Similar help and support threads for2: Is it possible to pass arguments to local hyperlinks to .cmd files?|
|Local HTML files won't load CSS (IE-10)||Browsers & Mail|
|best soft to find pass for Excel 2010 files ??||Microsoft Office|
|Create a Shortcut with arguments to exe file windows 7||General Discussion|
|Command-line wildcard arguments - not expanding||Software|
|XP Mode: Software Preview Works On Local Files But Not Files On Win7||Virtualization|
|Shortcut arguments - How do find them?||General Discussion|
|Deleting Files Out of AppData\Local||General Discussion|
|Our Sites ||Site Links ||About Us ||Find Us |
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd
All times are GMT -5. The time now is 11:15 AM.