@@ -20,7 +20,7 @@ Public Module ScriptAddin
20
20
''' <summary>optional additional path settings for ScriptExec</summary>
21
21
Public ScriptExecAddPath As String
22
22
''' <summary>optional additional environment settings for ScriptExec</summary>
23
- Public ScriptExecAddEnvironVars As Dictionary( Of String , String )
23
+ Public ScriptExecAddEnvironVars As Dictionary( Of String , String ) = New Dictionary( Of String , String )
24
24
''' <summary>If Script engine writes to StdError, regard this as an error for further processing (some write to StdError in case of no error)</summary>
25
25
Public StdErrMeansError As Boolean
26
26
''' <summary>for ScriptAddin invocations by executeScript, this is set to true, avoiding a MsgBox</summary>
@@ -73,7 +73,6 @@ Public Module ScriptAddin
73
73
Public Function startScriptprocess() As String
74
74
Dim errStr As String
75
75
avoidFurtherMsgBoxes = False
76
- ScriptExecAddEnvironVars = New Dictionary( Of String , String )
77
76
' get the definition range
78
77
errStr = getScriptDefinitions()
79
78
If errStr <> vbNullString Then Return "Failed getting ScriptDefinitions: " + errStr
@@ -988,35 +987,60 @@ Public Module ScriptAddin
988
987
End Sub
989
988
990
989
Public Sub insertScriptExample()
991
- If QuestionMsg( "Inserting Example Script definition starting in current cell, overwriting 8 rows and 3 columns with example definitions!" ) = MsgBoxResult.Cancel Then Exit Sub
990
+ If QuestionMsg( "Inserting Example Script definition starting in current cell, overwriting 14 rows and 3 columns with example definitions!" ) = MsgBoxResult.Cancel Then Exit Sub
991
+ Dim retval As String = InputBox( "Please provide a range name:" , "Range name for the example (empty name exits this)" )
992
+ If retval = "" Then
993
+ Exit Sub
994
+ Else
995
+ retval = "Script_" + retval
996
+ End If
992
997
Dim curCell As Range = ExcelDnaUtil.Application.ActiveCell
993
998
curCell.Value = "Dir"
994
999
curCell.Offset( 0 , 1 ).Value = "."
995
1000
curCell.Offset( 1 , 0 ).Value = "Type"
996
1001
curCell.Offset( 1 , 1 ).Value = "R"
1002
+ curCell.Offset( 1 , 2 ).Value = "n"
997
1003
curCell.Offset( 2 , 0 ).Value = "script"
998
1004
curCell.Offset( 2 , 1 ).Value = "yourScript.R"
999
- curCell.Offset( 2 , 2 ).Value = ". "
1005
+ curCell.Offset( 2 , 2 ).Value = "subfolder\from\Workbook\dir\where\yourScript.R\Is\located "
1000
1006
curCell.Offset( 3 , 0 ).Value = "scriptCell"
1001
- curCell.Offset( 3 , 1 ).Value = "# your script code in this cell"
1002
- curCell.Offset( 3 , 2 ).Value = ". "
1007
+ curCell.Offset( 3 , 1 ).Value = "# your script code In this cell"
1008
+ curCell.Offset( 3 , 2 ).Value = "subfolder\from\Workbook\dir\where\tempfile\For\scriptCell\Is\written "
1003
1009
curCell.Offset( 4 , 0 ).Value = "scriptRng"
1004
1010
curCell.Offset( 4 , 1 ).Value = "yourScriptCodeInThisRange"
1005
1011
curCell.Offset( 4 , 2 ).Value = "."
1006
1012
curCell.Offset( 5 , 0 ).Value = "arg"
1007
1013
curCell.Offset( 5 , 1 ).Value = "yourArgInputRange"
1008
- curCell.Offset( 5 , 2 ).Value = ". "
1014
+ curCell.Offset( 5 , 2 ).Value = "subfolder\from\Workbook\dir\where\tempfile\For\arg\Is\written "
1009
1015
curCell.Offset( 6 , 0 ).Value = "res"
1010
1016
curCell.Offset( 6 , 1 ).Value = "yourResultOutRange"
1011
- curCell.Offset( 6 , 2 ).Value = ". "
1012
- curCell.Offset( 7 , 0 ).Value = "diag "
1013
- curCell.Offset( 7 , 1 ).Value = "yourDiagramPlaceRange "
1017
+ curCell.Offset( 6 , 2 ).Value = "subfolder\from\Workbook\dir\where\tempfile\For\res\Is\expected "
1018
+ curCell.Offset( 7 , 0 ).Value = "rres "
1019
+ curCell.Offset( 7 , 1 ).Value = "yourResultOutRangeBeingRemovedInExcelBeforeRunningScript "
1014
1020
curCell.Offset( 7 , 2 ).Value = "."
1021
+ curCell.Offset( 8 , 0 ).Value = "diag"
1022
+ curCell.Offset( 8 , 1 ).Value = "yourDiagramPlaceRange"
1023
+ curCell.Offset( 8 , 2 ).Value = "subfolder\from\Workbook\dir\where\tempfile\For\diag\Is\expected"
1024
+ curCell.Offset( 9 , 0 ).Value = "path"
1025
+ curCell.Offset( 9 , 1 ).Value = "your\additional\folder\To\add\To\the\path"
1026
+ curCell.Offset( 9 , 2 ).Value = ".R"
1027
+ curCell.Offset( 10 , 0 ).Value = "envvar"
1028
+ curCell.Offset( 10 , 1 ).Value = "yourEnvironmentVar1"
1029
+ curCell.Offset( 10 , 2 ).Value = "yourEnvironmentVar1Value"
1030
+ curCell.Offset( 11 , 0 ).Value = "envvar"
1031
+ curCell.Offset( 11 , 1 ).Value = "yourEnvironmentVar2"
1032
+ curCell.Offset( 11 , 2 ).Value = "yourEnvironmentVar2Value"
1033
+ curCell.Offset( 12 , 0 ).Value = "dir"
1034
+ curCell.Offset( 12 , 1 ).Value = "your\scriptfiles\directory\overriding\the\current\workbook\folder"
1035
+ curCell.Offset( 13 , 0 ).Value = "exec"
1036
+ curCell.Offset( 13 , 1 ).Value = "yourOwnOverridingExecutable.exe"
1037
+ curCell.Offset( 13 , 2 ).Value = "/someSwitchForTheOverridingExecutable"
1015
1038
Try
1016
- ExcelDnaUtil.Application.ActiveSheet.Range(curCell, curCell.Offset( 7 , 2 )).Name = "Script_Example"
1039
+ ExcelDnaUtil.Application.ActiveSheet.Range(curCell, curCell.Offset( 13 , 2 )).Name = retval
1017
1040
Catch ex As Exception
1018
- UserMsg( "Couldn't name example definitions as 'Script_Example ': " + ex.Message)
1041
+ UserMsg( "Couldn't name example definitions as '" + retval + " ': " + ex.Message)
1019
1042
End Try
1043
+ ExcelDnaUtil.Application.ActiveSheet.Range(curCell, curCell.Offset( 0 , 2 )).EntireColumn.AutoFit
1020
1044
ScriptAddin.initScriptExecutables()
1021
1045
Dim errStr As String = ScriptAddin.startScriptNamesRefresh()
1022
1046
If Len(errStr) > 0 Then ScriptAddin.UserMsg( "refresh Error: " & errStr, True , True )
0 commit comments