-
-
Notifications
You must be signed in to change notification settings - Fork 654
Using COM with NVDA and Microsoft Word
This page provides a rough set of notes on getting started with COM calls via NVDA for Microsoft word.
- Open Microsoft word (with the content you wish to explore)
- Press NVDA+ctrl+z to open the NVDA Python Console
- Get access to a
TextInfo
object:tInfo = focus.makeTextInfo("caret")
Test the size of this range with:
tInfo._rangeObj.start
tInfo._rangeObj.end
You can modify these and then use tInfo._rangeObj.text
to see what is in the range.
Using the Microsoft Word VBA Object model reference is helpful to explore what is available. See https://msdn.microsoft.com/EN-US/library/office/ff837519.aspx (if this link breaks, and you are having trouble finding this, try searching for "microsoft word range object" and going back up the documentation hierarchy).
The Object model referred to in the VBA reference is available in your NVDA Python Console under tInfo._rangeObj
. This allows you try getting the number of hyperlinks in the range, see the text for one, and its address:
tInfo._rangeObj.hyperlinks.count
tInfo._rangeObj.hyperlinks.item(1).range.text
tInfo._rangeObj.hyperlinks.item(1).address
You will notice (in winword.cpp
) that there are calls to _com_dispatch_raw_method
and _com_dispatch_raw_propget
which rely on defines set at the top of the file, such as #define wdDISPID_RANGE_START 3
. Its important to be able to get these values. This can be done by querying the COM object for the ID for a name:
idisp = tInfo._rangeObj._comobj
idisp.GetIDsOfNames('hyperlinks')
# should output: [156]
- FAQ
- Application Support
- Connect
- Guides
- Extra Voices
- Log Files And Crash Dumps
- Log Levels (move to userguide / delete?)
This section will be moved to the NVDA repository as a priority
- Internals
- Notes Adding support for aria attributes to browsers
- Using COM with NVDA and Microsoft Word