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
 All Forums
 Origin Forum for Programming
 Forum for Automation Server/COM and LabVIEW
 Excel VBA - copy range & execute labtalk script

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
psoso Posted - 07/29/2018 : 3:54:06 PM
Origin Ver. and Service Release (Select Help-->About Origin): 9.1
Operating System: winxp

while being an absolute beginner isn't very helpful at all, I am still taken aback how I can't even get simple tutorial copies to work:

beginner project: from an open excel sheet, copy a range of strings into a new book in a new origin project. then run a labtalk script, save and exit.

While I can select my excel range, I cannot assign it to a variable that I can then insert into the origin range.

I also just cannot get the labtalk script to run with what I think should work.

Dim org As Origin.Application
Dim orgWkBk As Origin.WorksheetPage
Dim orgWks As Origin.Worksheet
Dim strPathName As Variant
Dim rangeexcel As Excel.range
Dim rangeori As Origin.DataRange

sheetname = ActiveSheet.Name
Range("c3", ActiveSheet.Range("c3").End(xlDown)).Select

' Create the Origin COM object, folder wkbk sheet and column works fine
Set org = New Origin.Application
org.NewProject
org.Execute ("sec -poc 1.5")
org.RootFolder.Folders.Add("Folder1").Activate 'add new folder
Set orgWkBk = org.WorksheetPages.Add
Set orgWks = orgWkBk.Layers(0)
orgWks.Columns.Add



Set rangeori = Wks.NewDataRange(0, 1)
rangeori.SetData = (ActiveSheet.range("c3", ActiveSheet.range("c3").End(xlDown)).Select)


org.Execute (name_of_custom_labtalkscript)


'saving also works
strPathName = Application.GetSaveAsFilename(sheetname, "Project files (*.OPJ),*.OPJ", 0)
org.Save (strPathName)
org.Execute ("sec -poc 1.5")
org.Exit

End Sub

2   L A T E S T    R E P L I E S    (Newest First)
psoso Posted - 08/09/2018 : 3:30:19 PM
thank you. with the additional help of some of the examples in the /SAMPLES folder I think I have ranges figured out.
I still don't understand the limitations of the execute command.
https://www.originlab.com/doc/COM/Classes/Application/Execute
In origin I have made a custom labtalk script many lines long (variable definitions, IFs and loops etc.) and would like to start it via vba.
Documentation makes it sound like it should work like:
app.Execute (name_of_custom_labtalkscript).
However, I can only get single x-functions to work this way.
I just assumed it would work similar to "excel.run(name_of_customexcelmacro)" ?
YimingChen Posted - 08/01/2018 : 4:48:45 PM
Hi Psoso,

Can you try the following script to set excel range to a variable and copy that into Origin worksheet. Please make sure [Book1]Sheet1 exists in Origin :


    Set rngDataAndParam = ActiveSheet.Range("c3", ActiveSheet.Range("c3").End(xlDown))
    pws = app.PutWorksheet("[Book1]Sheet1", rngDataAndParam.Value)


Please also check the webpage:
https://www.originlab.com/doc/COM/Classes/Application/PutWorksheet

Thank,

James

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000