osx - How to create table in Word document open in OpenOffice using REALbasic on Mac OS -
this code used create binary file:
dim efile folderitem dim output binarystream efile= getsavefolderitem("application/vnd.ms-word", "mydocument.doc") output.write "user name: "+" user name field"+chr(13) output.write "website: "+" website field"+chr(13) output.close i want insert table format in word document.
here's more details on how mac os x:
get little acquainted app "applescript editor".
enter following script new script window:
tell application "microsoft word" set d active document content of text object of d end tell if have text document open in word, , run script, should print plain text of in result pane below script code.
in same way can alter text in word document:
tell application "microsoft word" set d active document set content of text object of d "new text" end tell that's basics read , write text in word via applescript. learn how add text existing text or change fonts etc, need read "dictionary" of word, can open in applescript editor, see file menu.
for more applescript, visit http://www.macscripter.net
now, use realbasic, create script:
on run {newcontent} tell application "microsoft word" set d active document set content of text object of d newcontent end tell end run save script file (file extension .scpt), e.g. "setcontentinactiveworddocument.scpt"
then drag script file realbasic project, it'll appear item named "setcontentinactiveworddocument" in italics.
you can call setcontentinactiveworddocument function, passing string it.
e.g, write:
efile.launch() // should open existing word file if exists in "efile" setcontentinactiveworddocument("the new text") // replaces text in opened word file to create table in word document, things more complicated, though. can pass strings , numbers script rb way, if have array of values want place table, you'll have convert array values string unique separators, pass string script, in string gets split individual fields again.
it helps immensely if purchase "script debugger" - not lets single step through scripts provides "explorer" lets see values of running application, making easier figure out want access. used script debugger see how content using explorer. without this, you'd have figure out scripting dictionary, quite difficult if you're not experienced in it.
(later)
i attempted add or read table word 2008. can't work references tables in "active document", despite finding several examples on 'net suggest should work, this:
tell application "microsoft word" table 1 of active document end tell i can't tell if general problem word 2008 or particular installation. , have no other versions test with, sorry. leaves google examples , see if can make sense of it. in case, first develop , test code in script editor before trying make work realbasic.
also, google "word 2004 applescript reference", comprehensive guide on using word applescript.
Comments
Post a Comment