Author |
Topic  |
|
silkehl
Germany
Posts |
Posted - 02/21/2008 : 05:44:20 AM
|
Origin Version (Select Help-->About Origin):Origin 8.0 Operating System: Windows XP
Can it be that the function "PutWorksheet" only works properly if the data in a typed array? I want use the function in VBScript and the return value is always false. When I use this function in VB, the result is ok. Thank you for any help, Silke |
|
n/a
Posts |
Posted - 02/21/2008 : 9:14:52 PM
|
Hi, Silke
The function used in vbscript should be passed the data as reference. Would you mind pasting your code here if this doesn't work?
Cloud |
 |
|
silkehl
Germany
Posts |
Posted - 02/22/2008 : 02:47:50 AM
|
Thank you for your answer. I dont know the error. The example is so simple! Createpage and set pagestring work correct, but putworksheet not. Here my VB code:
Option Explicit private Const ORIGIN_WINTYPE_WKS = 2 Dim ebWksName,ebSaveFileName Dim OriginApp
Private Sub ConnectOrigin() Set OriginApp = GetObject("", "Origin.Application") OriginApp.Execute ("doc -ss 1") ebSaveFileName = OriginApp.LTStr("%Y") + OriginApp.LTStr("%G") end Sub
Private Sub DisconnectOrigin() OriginApp.IsModified = false OriginApp.Save (ebSaveFileName) OriginApp.Execute ("exit;") Set OriginApp = Nothing End Sub
Private Sub SendData() Dim iRowStart,str Dim d,b Dim data()
ebWksName = "MyData" str = "d=exist(" + ebWksName + ")" If OriginApp.Execute(str) Then d = OriginApp.LTVar("d") End If If d <> 2 Then ebWksName = OriginApp.CreatePage(ORIGIN_WINTYPE_WKS, ebWksName, "w") End If iRowStart = 0 Dim iRow,iCol ReDim data(5, 5) For iRow = 0 To 4 For iCol = 1 To 4 data(iRow, iCol) = iRow + iCol Next Next b = OriginApp.PutWorksheet(ebWksName, data) End Sub
Sub Main() ConnectOrigin SendData DisconnectOrigin end Sub Main
Thank you for help. Best regards Silke |
 |
|
Deanna
China
Posts |
Posted - 02/24/2008 : 8:54:31 PM
|
Hi Silke,
You can try to change the following code: b = OriginApp.PutWorksheet(ebWksName, data) into: b = OriginApp.PutWorksheet(ebWksName, (data) )
The pair of parenthesis forces the data variable to be passed by reference instead of value. I tested on my PC. The data could be passed into Origin.
Deanna OriginLab Technical Services
Edited by - Deanna on 02/24/2008 8:55:15 PM |
 |
|
silkehl
Germany
Posts |
Posted - 02/25/2008 : 03:24:52 AM
|
Hi Deanna,
Thank you for your help. It works.
Silke |
 |
|
|
Topic  |
|
|
|