kcvinu Posted July 27, 2015 Posted July 27, 2015 Hi all,I have an object from "ObjGet("Word.Application")". Can i get the word document's window title with this object. Thanks in advance. PS. Searched a lot in MSDN page for Application Members of word object. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only)
water Posted July 27, 2015 Posted July 27, 2015 The old _WordAttach (Autoit 3.3.8.1) function might give you an idea:expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name...........: _WordAttach ; Description ...: Attach to the first existing instance of Microsoft Word where the ; search string matches based on the selected mode. ; Parameters ....: $s_string - String to search for ; $s_mode - Optional: specifies search mode ; FileName = Name of the open document ; FilePath = (Default) Full path to the open document ; HWND = hwnd of the word window ; Text = Text from the body of the document ; Title = Title of the word window ; Return values .: On Success - Returns an object variable pointing to the Word.Application object ; On Failure - Returns 0 and sets @ERROR ; @ERROR - 0 ($_WordStatus_Success) = No Error ; - 1 ($_WordStatus_GeneralError) = General Error ; - 5 ($_WordStatus_InvalidValue) = Invalid Value ; - 7 ($_WordStatus_NoMatch) = No Match ; @Extended - Contains invalid parameter number ; Author ........: Bob Anthony ; =============================================================================================================================== Func _WordAttach($s_string, $s_mode = "FilePath") $s_mode = StringLower($s_mode) Local $o_windows, $return, _ $i_Extended, $s_ErrorMSG = "", $i_ErrorStatusCode = $_WordStatus_Success ; Setup internal error handler to Trap COM errors, turn off error notification Local $status = __WordInternalErrorHandlerRegister() If Not $status Then __WordErrorNotify("Warning", "_WordAttach", _ "Cannot register internal error handler, cannot trap COM errors", _ "Use _WordErrorHandlerRegister() to register a user error handler") Local $f_NotifyStatus = _WordErrorNotify() ; save current error notify status _WordErrorNotify(False) Local $o_Result = ObjGet("", "Word.Application") If @error = $_WordStatus_ComError And $WordComErrorNumber = -2147221021 And $WordComErrorWinDescription = "Operation unavailable" Then $i_ErrorStatusCode = $_WordStatus_NoMatch EndIf If $i_ErrorStatusCode = $_WordStatus_Success Then $o_windows = $o_Result.Application.Windows If Not IsObj($o_windows) Then $i_ErrorStatusCode = $_WordStatus_NoMatch EndIf EndIf If $i_ErrorStatusCode = $_WordStatus_Success Then For $o_window In $o_windows Switch $s_mode Case "filename" If $o_window.Document.Name = $s_string Then $i_ErrorStatusCode = $_WordStatus_Success $o_window.Activate() $return = $o_window.Application EndIf Case "filepath" If $o_window.Document.FullName = $s_string Then $i_ErrorStatusCode = $_WordStatus_Success $o_window.Activate() $return = $o_window.Application EndIf Case "hwnd" Local $h_hwnd = __WordGetHWND($o_window) If IsHWnd($h_hwnd) Then If $h_hwnd = $s_string Then $i_ErrorStatusCode = $_WordStatus_Success $o_window.Activate() $return = $o_window.Application EndIf EndIf Case "text" If StringInStr($o_window.Document.Range().Text, $s_string) Then $i_ErrorStatusCode = $_WordStatus_Success $o_window.Activate() $return = $o_window.Application EndIf Case "title" If ($o_window.Caption & " - " & $o_window.Application.Caption) = $s_string Then $i_ErrorStatusCode = $_WordStatus_Success $o_window.Activate() $return = $o_window.Application EndIf Case Else ; Invalid Mode $i_ErrorStatusCode = $_WordStatus_InvalidValue $s_ErrorMSG = "Invalid Mode Specified" $i_Extended = 2 EndSwitch Next If Not IsObj($return) Then $i_ErrorStatusCode = $_WordStatus_NoMatch EndIf EndIf ; restore error notify and error handler status _WordErrorNotify($f_NotifyStatus) ; restore notification status __WordInternalErrorHandlerDeRegister() Switch $i_ErrorStatusCode Case $_WordStatus_Success Return SetError($_WordStatus_Success, 0, $return) Case $_WordStatus_NoMatch __WordErrorNotify("Warning", "_WordAttach", "$_WordStatus_NoMatch") Return SetError($_WordStatus_NoMatch, 0, 0) Case $_WordStatus_InvalidValue __WordErrorNotify("Error", "_WordAttach", "$_WordStatus_InvalidValue", $s_ErrorMSG) Return SetError($_WordStatus_InvalidValue, $i_Extended, 0) Case Else __WordErrorNotify("Error", "_WordAttach", "$_WordStatus_GeneralError", "Invalid Error Status - Notify Word.au3 developer") Return SetError($_WordStatus_GeneralError, 0, 0) EndSwitch EndFunc ;==>_WordAttach 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
kcvinu Posted July 27, 2015 Author Posted July 27, 2015 @water , Thank you. Infact, i found it in my own. "$WordObject.ActiveDocument.Name" is what i want. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only)
water Posted July 27, 2015 Posted July 27, 2015 Yes, but the window title is a bit different. It is$WordObject.ActiveDocument.Name & " - Microsoft Word" kcvinu 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
kcvinu Posted July 27, 2015 Author Posted July 27, 2015 @water , yes. but i just need file name only. Anyway, i am playing with the methods and properties of Word object. It's interesting. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only)
water Posted July 27, 2015 Posted July 27, 2015 I know 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
kcvinu Posted July 27, 2015 Author Posted July 27, 2015 (edited) I know what do you mean by the "I know". You did the re-writing of the Word.au3 Thanks for such a nice UDF Edited July 27, 2015 by kcvinu Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only)
water Posted July 27, 2015 Posted July 27, 2015 When getting your feet wet with the Word Developer Reference you find a lot of useful information. Sometimes it gets too much so you do not know where to start and where to end.Happy reading kcvinu 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
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