This project has moved. For the latest updates, please go here.

Some problems

Jan 23, 2016 at 7:39 AM
Thanks Sebastian for your software.
But I have some problems with Access Add-In:
  1. NetOffice.AccessApi.TextBox (and any other controls) can't be cast to NetOffice.AccessApi.Control. Why?
  2. If I use ctl.Parent.Name then:
    'ctl.parent.name' threw an exception of type 'System.Runtime.InteropServices.COMException'.
    But ctl.UnderlyingObject.Parent.Name return value.
Regards,
Serge
Coordinator
Jan 24, 2016 at 9:07 PM
Hello Serge,

I've been looked at the definition in COM library and the interop assemblies.
Textbox doesnt inherites from Control.
It is:
TextBox : _Textbox : IAccessible

(tested in Office 2015)

Can you say which property throw the COMException ? (.Parent or .Parent.Name)

*Sebastian
Jan 25, 2016 at 6:44 AM
Hello Sebastian,
TextBox : _Textbox : IAccessible
Ok, I agree with you. There is some strange, which I can't understand.
Old code (simplistic):
Sub Test(section as Access.Section)
    Dim lst As New List(Of Access.Control) 
    Dim ctls = section.Controls
    For i = 0 To ctls.Count - 1
        Dim ctl = ctls(i)
        lst.Add(ctl)
    Next 
End Sub
This code works for
Imports Access = Microsoft.Office.Interop.Access
but doesn't work for
Imports Access = NetOffice.AccessApi (unable to cast in line lst.Add(ctl))
This is a very minor problem and allows me to get rid of the old roughness )
Can you say which property throw the COMException ? (.Parent or .Parent.Name)
.Parent
'ctl.Parent' threw an exception of type 'System.Runtime.InteropServices.COMException'
Data: {System.Collections.ListDictionaryInternal}
ErrorCode: -2146793279
HResult: -2146793279
HelpLink: Nothing
InnerException: Nothing
Message: "Исключение из HRESULT: 0x800A88C1"
Source: "Microsoft.VisualBasic"
StackTrace: "   в Microsoft.VisualBasic.CompilerServices.Symbols.Container.InvokeMethod(Method TargetProcedure, Object[] Arguments, Boolean[] CopyBack, BindingFlags Flags)" & vbCrLf & "   в Microsoft.VisualBasic.CompilerServices.NewLateBinding.CallMethod(Container BaseReference, String MethodName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, BindingFlags InvocationFlags, Boolean ReportErrors, ResolutionFailure& Failure)" & vbCrLf & "   в Microsoft.VisualBasic.CompilerServices.NewLateBinding.ObjectLateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)" & vbCrLf & "   в Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)"
TargetSite: {Void GetContainingTypeLib(System.Runtime.InteropServices.ComTypes.ITypeLib ByRef, Int32 ByRef)}
In my test this exception occurs for ComboBox and TabControl.
For other controls (ListBox, TextBox ...) this exception does not occurs.

Regards,
Serge
Jan 25, 2016 at 9:54 AM
In my test this exception occurs for ComboBox and TabControl.
I'm sorry, I am wrong. This exception occurs for all controls.

Regards,
Serge
Jan 28, 2016 at 9:16 AM
This exception occurs for all controls.
If control Parent is Form

Regards,
Serge