Skip to content

Commit 29cb9bc

Browse files
committed
fixed bug with new envvar
enhanced insert example
1 parent 67a2495 commit 29cb9bc

File tree

5 files changed

+42
-14
lines changed

5 files changed

+42
-14
lines changed

Distribution/ScriptAddin32.xll

0 Bytes
Binary file not shown.

Distribution/ScriptAddin64.xll

0 Bytes
Binary file not shown.

My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ Imports System.Runtime.InteropServices
3030
' You can specify all the values or you can default the Build and Revision Numbers
3131
' by using the '*' as shown below:
3232

33-
<Assembly: AssemblyVersion("1.0.0.6")>
34-
<Assembly: AssemblyFileVersion("1.0.0.6")>
33+
<Assembly: AssemblyVersion("1.0.0.7")>
34+
<Assembly: AssemblyFileVersion("1.0.0.7")>

ScriptAddin.vb

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Public Module ScriptAddin
2020
''' <summary>optional additional path settings for ScriptExec</summary>
2121
Public ScriptExecAddPath As String
2222
''' <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)
2424
''' <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>
2525
Public StdErrMeansError As Boolean
2626
''' <summary>for ScriptAddin invocations by executeScript, this is set to true, avoiding a MsgBox</summary>
@@ -73,7 +73,6 @@ Public Module ScriptAddin
7373
Public Function startScriptprocess() As String
7474
Dim errStr As String
7575
avoidFurtherMsgBoxes = False
76-
ScriptExecAddEnvironVars = New Dictionary(Of String, String)
7776
' get the definition range
7877
errStr = getScriptDefinitions()
7978
If errStr <> vbNullString Then Return "Failed getting ScriptDefinitions: " + errStr
@@ -988,35 +987,60 @@ Public Module ScriptAddin
988987
End Sub
989988

990989
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
992997
Dim curCell As Range = ExcelDnaUtil.Application.ActiveCell
993998
curCell.Value = "Dir"
994999
curCell.Offset(0, 1).Value = "."
9951000
curCell.Offset(1, 0).Value = "Type"
9961001
curCell.Offset(1, 1).Value = "R"
1002+
curCell.Offset(1, 2).Value = "n"
9971003
curCell.Offset(2, 0).Value = "script"
9981004
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"
10001006
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"
10031009
curCell.Offset(4, 0).Value = "scriptRng"
10041010
curCell.Offset(4, 1).Value = "yourScriptCodeInThisRange"
10051011
curCell.Offset(4, 2).Value = "."
10061012
curCell.Offset(5, 0).Value = "arg"
10071013
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"
10091015
curCell.Offset(6, 0).Value = "res"
10101016
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"
10141020
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"
10151038
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
10171040
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)
10191042
End Try
1043+
ExcelDnaUtil.Application.ActiveSheet.Range(curCell, curCell.Offset(0, 2)).EntireColumn.AutoFit
10201044
ScriptAddin.initScriptExecutables()
10211045
Dim errStr As String = ScriptAddin.startScriptNamesRefresh()
10221046
If Len(errStr) > 0 Then ScriptAddin.UserMsg("refresh Error: " & errStr, True, True)

deployForTest.cmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
@echo off
22
Set /P answr=deploy (r)elease (empty for debug)?
33
set source=bin\Debug
4+
If "%answr%"=="r" (
5+
set source=bin\Release
6+
)
7+
echo copying from %source%
48
if exist "C:\Program Files\Microsoft Office\root\" (
59
echo 64bit office
610
copy /Y %source%\ScriptAddin-AddIn64-packed.xll "%appdata%\Microsoft\AddIns\ScriptAddin.xll"

0 commit comments

Comments
 (0)