Page 1 of 1

VBScript and Publication variables

PostPosted: Thu Apr 09, 2015 3:07 pm
by ebear
Hello All,

I never really tried VBScripts via functions in Neobook, now I have a question about VBScripts and Neobook Variables.
Below is a part of my script. I want to write into A excel file, the text "Customer name:" is normally written but the Neobook variables are empty

Code: Select all
obj
. First I tried this:
objExcel.Range("A1").Select
objExcel.ActiveCell.FormulaR1C1 = "Customer name:"
objExcel.Range("B1").Select
objExcel.ActiveCell.FormulaR1C1 = "[Fis.CoreIn.RID]"

.Then this:
objExcel.Range("A1").Select
objExcel.ActiveCell.FormulaR1C1 = "Customer name:"
objExcel.Range("B1").Select
objExcel.ActiveCell.FormulaR1C1 = [Fis.CoreIn.RID]

.From the Neobook manual, I tried publication.nbGetVar
objExcel.Range("A1").Select
objExcel.ActiveCell.FormulaR1C1 = "Customer name:"
objExcel.Range("B1").Select
objExcel.ActiveCell.FormulaR1C1 = publication.nbGetVar( "[Fis.CoreIn.RID]" )


The three test above gave no results, can anyone help me with this problem.

Best regards,

Eric

Re: VBScript and Publication variables

PostPosted: Thu Apr 09, 2015 4:06 pm
by Gaev
Eric:

Try the following steps to find the root cause ...

1) I believe that you said that the text "Customer name:" was being placed in cell A1 ... so, try the same hard-coded value for cell B1 ...
Code: Select all
objExcel.Range("A1").Select
objExcel.ActiveCell.FormulaR1C1 = "Customer name:"
objExcel.Range("B1").Select
objExcel.ActiveCell.FormulaR1C1 = "John Smith"

If that does not work, I am stumped ... otherwise, continue with (2).

2)
Code: Select all
AlertBox "Fis.CoreIn.RID" "[Fis.CoreIn.RID]"
Call "yourVBScript Function"


... and this code for "yourVBScript Function" ...
Code: Select all
objExcel.Range("A1").Select
objExcel.ActiveCell.FormulaR1C1 = "Customer name:"
objExcel.Range("B1").Select
cellB1 = publication.nbGetVar( "[Fis.CoreIn.RID]" )
MsgBox cellB1
objExcel.ActiveCell.FormulaR1C1 = cellB1

... so you can verify the contents of database field [Fis.CoreIn.RID] before and inside the Function.

Let us know what you observed.


Another way to approach this would be to pass the values as parameters e.g. ...
Code: Select all
Call "UpdateExcelCell" "A1" "Customer name:"
Call "UpdateExcelCell" "B1" "[Fis.CoreIn.RID]"
etc. etc.

... and within the function, use [%1], [%2] to set the cell values.

Re: VBScript and Publication variables

PostPosted: Sun Apr 12, 2015 6:24 am
by ebear
Hello Gaev,

I have it working, the problem was that I thought that the Neobook variables where global available also for VBscripts. But it has really to go via "publication.nbGetVar".
Never had the need before to use VBscripts.

Thanks a lot for your support.

Best regards,

Eric