Kowala Posted April 25, 2014 Share Posted April 25, 2014 It seems it is time to reach out for help. I have spent a day researching these forums and just cant seem to get my head around what seems to be a basic process. Goal: Create a Script/GUI window that takes the currently active Word document, triggers a input field window for the file name and saves the document without opening the Microsoft Word Save As dialog window. I would offer to post my scripts, but at this point after this much testing it is a jumble. I am trying to use the ObjGet command to pull up the currently opened instance of Word up. I do not need to launch a new version of Word. I have tried without sucess to use the _WordDocGetCollection command to specify the currently active document. No sucess using this variable either. I have also played with _WordDocSaveAs with minor success. Anyway...apologies for the newbie spam. Respectfully, Clifton Link to comment Share on other sites More sharing options...
water Posted April 26, 2014 Share Posted April 26, 2014 To connect to an active Word document use function _Word_DocAttach (with AutoIt 3.3.10.2) or the similar function in 3.3.8.1. Kowala 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
Kowala Posted April 29, 2014 Author Share Posted April 29, 2014 Water, your advice on using _Word_DocAttach was great! I ended up creating a Save As GUI successfully! I am working on the second half of this project, creating a Save dialog window that allows saving over the previous document name. I am having issues as the _Word_DocAttach seems to require the exact document name when using the FileName filter. I have not been able to figure out how to use _Word_DocAttach and pull the current name of the document sucessfully. Line 11 Global $oDoc = _Word_DocAttach($oWord, *.*, "FileName") I have attached my current code. #include <Word.au3> #include <MsgBoxConstants.au3> ; Create application object Global $oWord = _Word_Create() If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSaveAs Example", _ "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; Attach to the test document by "FileName" and set focus to the window Global $oDoc = _Word_DocAttach($oWord, *.*, "FileName") If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAttach Example", _ "Error attaching to 'Document1' by 'FileName'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;Insert text at the beginning; to be removed prior to deployment. Global $oRange = _Word_DocRangeSet($oDoc, -1) #forceref $oRange $oRange.Text = "Bold text at the beginning. " $oRange.Bold = True ; Save document _Word_DocSave($oDoc) If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSave Example", _ "Error saving the Word document." & @CRLF & "@error = " & @error & ", @extended = " & @extended) MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSave Example", "Document successfully saved as '" & _ $oDoc.FullName & "'") Link to comment Share on other sites More sharing options...
water Posted May 3, 2014 Share Posted May 3, 2014 You could use _Word_DocGet to retrieve a collection of documents and then check property "Name" of every document. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
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