Jaafar Tribak
Well-known Member
- Joined
- Dec 5, 2002
- Messages
- 9,806
- Office Version
- 2016
- Platform
- Windows
Hi all,
Not sure if this is the right section of the forum to ask this question but I am trying to get the accessibility names of the workbook scrollbars and tabs .. The AccName function returns a string that is language dependent so when I run the code on my machine, I get the AccName in French. (I am using the french version of office)
As part of a small project I am working on, I need to know the English equivalent.
Can anyone please tell me what the exact strings they get in the immediate window after running the Test Macro ?
Regards.
In a Standard Module:
Not sure if this is the right section of the forum to ask this question but I am trying to get the accessibility names of the workbook scrollbars and tabs .. The AccName function returns a string that is language dependent so when I run the code on my machine, I get the AccName in French. (I am using the french version of office)
As part of a small project I am working on, I need to know the English equivalent.
Can anyone please tell me what the exact strings they get in the immediate window after running the Test Macro ?
Regards.
In a Standard Module:
Code:
Option Explicit
[URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=If"]#If[/URL] VBA7 Then
Declare PtrSafe Function AccessibleObjectFromWindow Lib "OLEACC.DLL" (ByVal hwnd As LongPtr, ByVal dwId As Long, ByVal riid As LongPtr, ppvObject As Any) As Long
Declare PtrSafe Function AccessibleChildren Lib "oleacc" (ByVal paccContainer As Office.IAccessible, ByVal iChildStart As Long, ByVal cChildren As Long, ByRef rgvarChildren As Any, ByRef pcObtained As Long) As Long
Declare PtrSafe Function IIDFromString Lib "ole32.dll" (ByVal lpsz As LongPtr, ByVal lpiid As LongPtr) As LongPtr
Declare PtrSafe Function FindWindowEx Lib "User32" Alias "FindWindowExA" (ByVal hWnd1 As LongPtr, ByVal hWnd2 As LongPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPtr
[URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=Else"]#Else[/URL]
Declare Function AccessibleObjectFromWindow Lib "OLEACC.DLL" (ByVal hwnd As Long, ByVal dwId As Long, ByVal riid As Long, ppvObject As Any) As Long
Declare Function AccessibleChildren Lib "oleacc" (ByVal paccContainer As Office.IAccessible, ByVal iChildStart As Long, ByVal cChildren As Long, ByRef rgvarChildren As Any, ByRef pcObtained As Long) As Long
Declare Function IIDFromString Lib "ole32.dll" (ByVal lpsz As Long, ByVal lpiid As Long) As Long
Declare Function FindWindowEx Lib "User32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
[URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=End"]#End[/URL] If
Const S_OK = &H0
Const OBJID_SELF = &H0&
Const CHILDID_SELF = &H0&
Const ID_ACCESSIBLE As String = "{618736E0-3C3D-11CF-810C-00AA00389B71}"
Sub Test()
Dim tGUID(0 To 3) As Long
Dim oIAc As IAccessible
Dim vAcc As Variant, vAccChild As Variant
Dim i As Long
Dim bVerScroll As Boolean, bHorScroll As Boolean, bTabs As Boolean
On Error GoTo errHandler
With ThisWorkbook.Windows(1)
bVerScroll = .DisplayVerticalScrollBar
bHorScroll = .DisplayHorizontalScrollBar
bTabs = .DisplayWorkbookTabs
.DisplayVerticalScrollBar = True
.DisplayHorizontalScrollBar = True
.DisplayWorkbookTabs = True
End With
If IIDFromString(StrPtr(ID_ACCESSIBLE), VarPtr(tGUID(0))) = S_OK Then
If AccessibleObjectFromWindow(FindWindowEx(FindWindowEx(Application.hwnd, 0, "XLDESK", vbNullString), 0, "EXCEL7", vbNullString), OBJID_SELF, VarPtr(tGUID(0)), oIAc) = S_OK Then
Set vAcc = oIAc
AccessibleChildren vAcc, 3, 1, vAcc, 1
For i = 0 To oIAc.accChildCount - 1
AccessibleChildren vAcc, i, 1, vAccChild, 1
Debug.Print vAccChild.accName(CHILDID_SELF)
Next i
End If
End If
errHandler:
With ThisWorkbook.Windows(1)
.DisplayVerticalScrollBar = bVerScroll
.DisplayHorizontalScrollBar = bHorScroll
.DisplayWorkbookTabs = bTabs
End With
End Sub
Last edited: