07.07.2015 Views

COM/MTS Guide - Prolifics

COM/MTS Guide - Prolifics

COM/MTS Guide - Prolifics

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Working with <strong>COM</strong> Componentsvars wsid, cidproc screen_enter{wsid = sm_obj_create("Excel.Sheet")cid = sm_obj_get_property(wsid, "Application.ActiveSheet")}proc setcell{call sm_obj_set_property \(cid, 'Range(":(col):(row)").Value', CellValue)}The following procedures create a Microsoft Word document. For more information,refer to Microsoft documentation on how to use OLE Automation with MicrosoftWord.vars word// Run "Word" and get the Application objectword = sm_obj_create ("Word.Application")// Add a new document (untitled)call sm_obj_call (word, "Documents.Add")// Add some sample textcall sm_obj_call \(word, "Selection.TypeText", "This is some text")// Save the document with the specified name// If you do not give a full path, the file will be// put into Word's notion of current directory// Note that colons must be doubled in JPLcall sm_obj_call \(word, "ActiveDocument.SaveAs", "C::\Test.doc")// Quit Wordcall sm_obj_call (word, "Quit")// and destroy the <strong>COM</strong> objectcall sm_obj_delete_id (word)Accessing the Component's PropertiesProperties in <strong>COM</strong> components generally contain the application state information.You can use the sm_obj_set_property and sm_obj_get_property functions toaccess properties. The following example sets a property on the component associatedwith the id variable:ret = sm_obj_set_property(id, "PropName", "PropSetting")<strong>COM</strong>/<strong>MTS</strong> <strong>Guide</strong> 4-5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!