Jump to content

Want to create word documents with autoname


Recommended Posts

I want to create a great many word documents based on names and dates and types.

Simply i just need to know that how can i call strings which are mentioned either earlier or by collected by gui created with AUTOIT. FOR EXAMPLE

Like in this script

#Include <Misc.au3>
#include <GUIConstants.au3>
GUICreate( "Get date", 210,190)
$document = 'Follow-Up'
$Date = GUICtrlCreateMonthCal ("",10, 10)
GUISetState()
While 1
Sleep ( 50 )
If _IsPressed("01") Then
#include <Word.au3>
;$calldate = GUICtrlRead($Date)
$oWordApp = _WordCreate (@DesktopDir & "\Test.doc"); RIGHT HERE I WANT TO SEND THE STRING $Date and $document 
;Run ('notepad.exe')
;WinWaitActive ("Untitled - Notepad")
;Send (GUICtrlRead($Date))
ExitLoop
EndIf
WEnd
Link to comment
Share on other sites

Try this:

#include <Word.au3>

#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Test", 342, 133)
$Label1 = GUICtrlCreateLabel("How many Word files should be created?", 8, 8, 198, 17)
$Input1 = GUICtrlCreateInput("10", 208, 4, 121, 20)
$Button1 = GUICtrlCreateButton("GO", 208, 72, 123, 49)
$Label2 = GUICtrlCreateLabel("Ouput Path:", 8, 40, 61, 17)
$Input2 = GUICtrlCreateInput(@ScriptDir, 72, 36, 257, 21)
;~ $Date1 = GUICtrlCreateDate("", 8, 88, 186, 21, $DTS_SHORTDATEFORMAT)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Create_Word(GUICtrlRead($Input1))
    EndSwitch
WEnd

Func Create_Word($n)
    GUICtrlSetState($Button1, $GUI_DISABLE)
    Local $i, $path = GUICtrlRead($Input2)
    Local $filename
    For $i = 1 To $n
        $filename = $path & "\Test_" & @YEAR & @MON & @MDAY & "_" & @HOUR & @MIN & @SEC & ".doc"
         $oWordApp = _WordCreate ($path & $filename, 0, 0)
         If @error Then Return SetError(1, @extended, _WinAPI_ShowError("Unable to create Word doc!"))
         $oDoc = _WordDocGetCollection ($oWordApp, 0)
         $oDoc.Range.InsertAfter ($filename)
        _WordDocSave ($oDoc)
        _WordQuit ($oWordApp)
        Sleep(1000)
     Next
     GUICtrlSetState($Button1, $GUI_ENABLE)
     MsgBox(0, "Ready", "Done!", 10)
     Return SetError(0)
EndFunc

For me it is not working because Word.au3 seems to be not compatible with Word2010! :graduated:

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Just tested a little and found that if you're running on a 64bit machine having 32bit Office 2010 installed, Word needs to be open and running (winword32.exe process exist) and the script needs to be started as 32bit (#AutoIt3Wrapper_UseX64=n), then it works for me.

Link to comment
Share on other sites

Indeed, I'm using Win7 x64 but I'm using also Office2010 x64! :graduated:

And it is not working for me with #AutoIt3Wrapper_UseX64=n, compiled, nor when Word is running.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 3 years later...

here are some word creating APIs i have been using to create work documents. check out:

Public Function CreateEmptyDOCXDocumentDemo(pageCount As Integer) As DOCXDocument

    Return New DOCXDocument(pageCount)
End Function

while i was compliing word document creating codes, i want to add some processing method into it.

so i can edit created word. any help would be appreciated.

Edited by passimage
Link to comment
Share on other sites

Welcome to AutoIt and the forum!

This thread is more than 3 years old. I suggest to create a new one.

Now AutoIt comes with a new Word UDF.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...