Jump to content
Sign in to follow this  
computelgt

Looking for a way to automate MsWord

Recommended Posts

computelgt

Hello is there a way to autosave all open word docments to MyDocs every 5 min. The reason I need a real saved copy instead the autosave option in MsWord does not really save a copy.

Share this post


Link to post
Share on other sites
water

You can either use the Word UDF that comes with AutoIt. Or write the code yourself (I can provide some assistance here).


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
computelgt

I would apreciate any help I would like for it to save all open word documents to MyDocs every 5min. I used the search function on this forum like I always do this is the first time I cant find an answer.

Share this post


Link to post
Share on other sites
water

Something like this?

$oWord_Error = ObjEvent("AutoIt.Error", "_Word_ErrorHandler") ; Creates a custom error handler
$oWord_Appl = ObjGet("", "Word.Application") ; Connect to the Word application
If @error Then Exit MsgBox(16, "Error", "Error returned when connecting to the Word application. @error = " & @error)
For $oWord_Doc In $oWord_Appl.Documents ; Loop through all documetns
    $oWord_Doc.Save                  ; Save the document
    If @error Then Exit MsgBox(16, "Error", "Error returned when saving document " & $oWord_Doc.FullName & ". @error = " & @error)
Next
Exit


Func _Word_ErrorHandler()

    Local $bHexNumber = Hex($oWord_Error.number, 8)
    Local $sWord_Error = "COM Error Encountered in " & @ScriptName & @CRLF & _
            "@AutoItVersion = " & @AutoItVersion & @CRLF & _
            "@AutoItX64 = " & @AutoItX64 & @CRLF & _
            "@Compiled = " & @Compiled & @CRLF & _
            "@OSArch = " & @OSArch & @CRLF & _
            "@OSVersion = " & @OSVersion & @CRLF & _
            "Scriptline = " & $oWord_Error.scriptline & @CRLF & _
            "NumberHex = " & $bHexNumber & @CRLF & _
            "Number = " & $oWord_Error.number & @CRLF & _
            "WinDescription = " & StringStripWS($oWord_Error.WinDescription, 2) & @CRLF & _
            "Description = " & StringStripWS($oWord_Error.description, 2) & @CRLF & _
            "Source = " & $oWord_Error.Source & @CRLF & _
            "HelpFile = " & $oWord_Error.HelpFile & @CRLF & _
            "HelpContext = " & $oWord_Error.HelpContext & @CRLF & _
            "LastDllError = " & $oWord_Error.LastDllError
    MsgBox(64, "Word UDF - Debug Info", $sWord_Error)

EndFunc   ;==>_Word_ErrorHandler

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
computelgt

Thank you I have been using yout autoit code and it seems to be working just fine.

Share this post


Link to post
Share on other sites
water

Glad you got your problem solved ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  

×