SadBunny Posted May 27, 2008 Posted May 27, 2008 (edited) Hi!I have been searching and reading a lot, but get way astray from what I need.I need something that is very easy to explain but seems hard to do (though I am sure I am merely overlooking that obvious, idiot foolproof, three-line-max solution once again - someone kick me please).I want to be able to copy-paste the contents of a .RTF file, in which I put a Lotus document first, to a new lotus document.In fact I now do this:1 - open RTF file in Wordpad2 - CTRL-A, CTRL-C3 - go back to Lotus Notes, make a new e-mail4 - CTRL-V and send e-mailOfcourse this is very easy to accomplish, but it needs to actually open the RTF document in Wordpad. Since what you get when you open an RTF file in Notepad and CTRL-C it, is different for some wordpad settings, it will not do for multiple users.So I would like to be able to read the RTF format directly from the file somehow, without opening Wordpad. But since I need to put it into the Lotus app from the copypaste buffer, still as RTF format, I can't just FileRead it /edit: for clarity: this just puts all tags in the RTF file in the e-mail as text (which gets formatted as normal text by Lotus), while copypasting from the Wordpad window does do exactly what I want.When I search for some info on the forum, I come to all kinds of difficult DLL stuff, of which everybody says its extremely powerful, but I can't imagine manually having to use something called CallBack functions or subclassing multithreads for this (never heard of any of that before) and having to learn how all that .DLL manipulation work is done.Please tell me I am trying to reinvent the wheel?? Edited June 20, 2008 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you.
SadBunny Posted June 20, 2008 Author Posted June 20, 2008 4 weeks later... I guess it's time to *bump* Roses are FF0000, violets are 0000FF... All my base are belong to you.
DaRam Posted June 20, 2008 Posted June 20, 2008 That is indeed a very considerate amount of time before a bump You could create a Rich Text Edit Control presuming you have the file MSCOMCT2.OCX in system32 (standard), and insert the RTF file contents to it, like so: Create a GUI, then $oRP = ObjCreate("RICHTEXT.RichtextCtrl.1") $GUIActiveX = GUICtrlCreateObj($oRP, 10, 10, 400, 260); Embedd it in your GUI GUICtrlSetPos($GUIActiveX, 10, 10, 300, 160); position it as required. $oRP.FileName = "d:\path\to\Test.Rtf"; Could be wrong about the method here. But the problem is as far as I know the RTC does not have an inherent copy to clipboard method. You could check this page for ideas: http://support.microsoft.com/kb/258513 The other alt. is to use the WORD UDF: #include <Word.au3> $oWordApp = _WordCreate () $oDoc = _WordDocOpen ($oWordApp, "d:\path\to\Test.Rtf") ; At this Point you need to Send a CTRL-A (Select All) ; And then a CTRL-C (Copy to Clipboard) _WordQuit ($oWordApp) ; Code to Activate Lotus Notes ; Send Keys to Create a new e-mail ; Send CTRL-V (Paste RTF) ; Send ALT-S or whaterver Key required to send the e-mailHope this helps. 4 weeks later... I guess it's time to *bump*
Moderators big_daddy Posted June 20, 2008 Moderators Posted June 20, 2008 The Word piece could be written like so... #include <Word.au3> $sFilePath = @ScriptDir & "\Test.rtf" $oWordApp = _WordCreate($sFilePath, 0, 0) $oDoc = _WordDocGetCollection($oWordApp, 0) With $oDoc .Select .Selection.Copy EndWith _WordQuit($oWordApp)
SadBunny Posted June 20, 2008 Author Posted June 20, 2008 (edited) Thanks a lot BigDaddy!Only it doesn't seem to work right. I get the following error:D:\_AutoIt\_Projects\test.au3 (11) : ==> The requested action with this object has failed.:.Selection.Copy.Selection^ ERRORI tried it with my original .rtf documents... Then I thought I'd test with actual word documents, one in the Word 2003 .doc format and one in the Word 2007 .docx format, but I got the same error.The exact code I used was:#include <Word.au3> $sFilePath = "c:\test.doc" $oWordApp = _WordCreate($sFilePath, 0, 0) $oDoc = _WordDocGetCollection($oWordApp, 0) With $oDoc .Select .Selection.Copy EndWith _WordQuit($oWordApp)oÝ÷ Ù8^¡¸ÞrÛajج§^o+ayj+uû§rبȬ½©bu©ÝºÆëa¢è!mçºÇ¢|h¶¢YhÂ)àjëh×6$oDoc.Range.insertAfter("This is some text to insert.") _WordDocSaveAs($oDoc,"c:\Test2.doc")... then it works as expected (i.e. puts the string behind the already existing document and saves it nicely as a perfectly usable Test2.doc).Am I missing something? /edit: fixed a number of typos that I seem to have made due to anxiety related to an e-mail from an old flame I just received Edited June 20, 2008 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you.
Moderators big_daddy Posted June 20, 2008 Moderators Posted June 20, 2008 Can you add _WordErrorHandlerRegister() toward the top of the code. Hopefully we will get a more useful error message.
SadBunny Posted June 20, 2008 Author Posted June 20, 2008 (edited) Thanks...I got the following:>Running:(3.2.12.0) :\_AutoIt\autoit3.exe "D:\_AutoIt\_Projects\test.au3" --> COM Error Encountered in test.au3----> $WordComErrorScriptline = 11----> $WordComErrorNumberHex = 80020006----> $WordComErrorNumber = -2147352570----> $WordComErrorWinDescription = Onbekende naam. /edit: This means 'unknown name'----> $WordComErrorDescription = ----> $WordComErrorSource = ----> $WordComErrorHelpFile = ----> $WordComErrorHelpContext = ----> $WordComErrorLastDllError = 0+>18:51:02 AutoIT3.exe ended.rc:0... but I have no idea how that should help me, since I am still very uncomfortable troubleshooting dll and/or object problems... Tnx for your time! Edited June 20, 2008 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you.
Moderators big_daddy Posted June 20, 2008 Moderators Posted June 20, 2008 Try this... #include <Word.au3> $sFilePath = "c:\test.doc" _WordErrorHandlerRegister() $oWordApp = _WordCreate($sFilePath, 0, 0) $oDoc = _WordDocGetCollection($oWordApp, 0) $oDoc.Select $oWordApp.Selection.Copy _WordQuit($oWordApp)
SadBunny Posted June 20, 2008 Author Posted June 20, 2008 (edited) Freakin' perfect! Thanks a lot, this little piece of script you wrote will save me a sh*tload of time! (Actually I already did write a working script, which opened the rtf documents in wordpad, used Send() to copypaste it, close the wordpad instance, and paste it in Lotus... But that was ugly, slow and error-prone. That's the why of my original enquiry.) Edited June 20, 2008 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now