sancarn / stdVBA

VBA Standard Library - A Collection of libraries to form a common standard layer for modern VBA applications.
MIT License
295 stars 60 forks source link

stdAcc Object doesn't supported error #97

Closed phobo3s closed 6 months ago

phobo3s commented 6 months ago

i am using this function: stdAcc.CreateFromHwnd(activeHwnd).PrintDescTexts("C:\Users\user.name\Desktop\test.txt") and get this error at some point "Object doesn't support this property or method"

when i trace the error back i found this; ` Public Sub PrintDescTexts(Optional ByVal sToFilePath As String = "", Optional ByVal bPrintToDebug As Boolean = True, optional ByVal sPath As String = "P", Optional ByVal fileNum As Long = 0)

'Open file is file name passed and file num not given

Dim bFileOpened As Boolean

If fileNum = 0 And Len(sToFilePath) > 0 Then
    bFileOpened = True
    fileNum = FreeFile()
    Open sToFilePath For Output As #fileNum
End If
'Loop over all children
Dim child As stdAcc
Dim iIndex As Long: iIndex = 0
For Each child In children
    'Get child index for path
    iIndex = iIndex + 1
    'Create path string
    Dim myPath As String: myPath = sPath & "." & iIndex
    'If file has been opened, print data to file
    If fileNum <> 0 Then Print #fileNum, myPath & ". " & child.Text  <~~~~~~~this is where the error raises. 
    'Only print to debug if bPrintToDebug
    If bPrintToDebug Then Debug.Print myPath & ". " & child.Text
    'Recurse to all children
    Call child.PrintDescTexts(sToFilePath, bPrintToDebug, myPath, fileNum)
Next
'Only close file if file was opened within sub
If bFileOpened Then
    Close #fileNum
End If

End Sub `

i think not all child support .text method. image

sancarn commented 6 months ago

Text is a concatenation of Name, Value, DefaultAction, Description, Role, Help, HelpTopic and KeyboardShortcut. Looks like in this case Help was not supported, and that's the only one we don't have Error catches for so that makes some sense. I'll add, but I wish I knew a better way of doing this... Or even why these even throw errors. Are they just returning E_NOTIMPLEMENTED ?