The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 using automation server with VBScript
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

silkehl

Germany
Posts

Posted - 02/21/2008 :  05:44:20 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

silkehl

Germany
Posts

Posted - 02/22/2008 :  02:47:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Deanna

China
Posts

Posted - 02/24/2008 :  8:54:31 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

silkehl

Germany
Posts

Posted - 02/25/2008 :  03:24:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Deanna,

Thank you for your help. It works.

Silke
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000