VBScript and Publication variables

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

Locked
User avatar
ebear
Posts: 270
Joined: Wed Jan 18, 2012 3:12 am
Location: Vrchlabi - Czech republic
Contact:

VBScript and Publication variables

Post 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
Last edited by ebear on Fri Apr 10, 2015 1:10 am, edited 1 time in total.
http://www.lunarsoftware.eu - Lunar Software ERP database Development. Manufacturing processes, Document management, QMS, Stock management. Standalone solutions or connected to Helios Orange and other ERP systems.
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: VBScript and Publication variables

Post 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.
User avatar
ebear
Posts: 270
Joined: Wed Jan 18, 2012 3:12 am
Location: Vrchlabi - Czech republic
Contact:

Re: VBScript and Publication variables

Post 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
http://www.lunarsoftware.eu - Lunar Software ERP database Development. Manufacturing processes, Document management, QMS, Stock management. Standalone solutions or connected to Helios Orange and other ERP systems.
Locked