Sign in to follow this  
Followers 0
Kowala

Word 2010 - Save As

4 posts in this topic

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

Share this post


Link to post
Share on other sites



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.

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 & "'")

Share this post


Link to post
Share on other sites

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 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
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  
Followers 0