Jump to content

Write to word file


Recommended Posts

I have a RichEdit and the content of said Edit should be saved to a .doc file. I already found the Word User Defined Functions (http://www.autoitscript.com/autoit3/docs/libfunctions/Word%20Management.htm), but I can't seem to find a way to actually write to that file. This is the code I have:

$MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}"
$where= FileSaveDialog("Plan Speichern", $MyDocsFolder,"Microsoft Word Dokumente (*.doc)", 2)
    If StringInStr($where,".doc") Then
        $word = _Word_Create(false,true)
        $doc = _Word_DocAdd($word)
        _Word_DocSaveAs($doc,$where)
        $infile =  _GUICtrlRichEdit_StreamToFile($Edit1, $where) ;this is what I tried 
        _Word_DocSave($doc)
        _Word_DocClose($doc)
        _Word_Quit($word)
    Else
        $wohinexport = $wohinexport & ".doc"
        $word = _Word_Create(false,true)
        $doc = _Word_DocAdd($word)
        _Word_DocSaveAs($doc,$where)
        $infile =  _GUICtrlRichEdit_StreamToFile($Edit1, $where)
        _Word_DocSave($doc)
        _Word_DocClose($doc)
        _Word_Quit($word)
    EndIf

If anyone could thell me what the correct function is to write to that document, I would be so happy :)

Thank you,

Reinhardt1julian

Edited by Reinhardt1julian
Link to comment
Share on other sites

See the examples for the _Excel_RangeDocSet functions. You set the cursor and then insert text at this location.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Sure there is a way.

$vRange = $oDoc.Range
$vRange.InsertBefore("Text you want to insert")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...