VB.Net Examples 3 - Create and Use Cursors in Writer

In this continuation of my ‘Examples’ I am hoping to have someone explain how to use VBNet to get a usable cursor to move around inside a document. In particular I want to add an image into a TextTable Cell and also locate text somewhere ~not~ in a TextTable and add text there.

I asked this question in my original Post “VB.Net Examples.” It had not been addressed by anyone there; but I ended the discussion there anyway realizing my requests, if answered there, would have made that post much too long.

I have been able to ‘Get’ xTextCursors, xTextViewCursors, xViewCursors and even xTextTableCursors, but they are each ‘gotten’ as a ‘TransparentProxy’ which I can do nothing with. I’ve attempted numerous CType and DirectCast methods to arrive at usable variables but nothing has worked. I’ve also studied the subjects of ‘Proxies’ and ‘Reflection’ and admittedly the discussions and examples I’ve read are too abstract for my little mind to understand or apply. There are also a number of other cursors I have not experimented with and am uncertain of their value or intended usage.

So my request here is for any working VBNet code examples which demonstrate the use of various cursors. Thanks in advance for any help that shows me how to manipulate cursors in VBNet code!!

The following LOBasic Code runs and works to move the blinking cursor down 1 (line or cell row apparently) without complaint, but when I convert it to (working) VB.Net Code which follows, but the blinking cursor remains in the same location. I’ve entered text manually after running the VB.Net Code and the text appears in the original cursor location (unremarkably). I understand there are multiple cursors in the LOAPI…

LOBasic Code
sub MoveCursorDown1X
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(“com.sun.star.frame.DispatchHelper”)
rem ----------------------------------------------------------------------
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = “Count”
args1(0).Value = 1
args1(1).Name = “Select”
args1(1).Value = false
dispatcher.executeDispatch(document, “.uno:GoDown”, “”, 0, args1())
end sub

VBNet Code
Public Shared Sub MoveCursor(ByRef strDirection As String, ByRef intMoveCount As Integer)
Dim args1(1) As unoidl.com.sun.star.beans.PropertyValue
args1(0) = CreateProp(“Count”, New uno.Any(1))
args1(1) = CreateProp(“Select”, New uno.Any(True))
For i = 0 To intMoveCount
Select Case strDirection
Case “Up”
loXDispatchHelper.executeDispatch(loXDispatchProvider, “.uno:GoUp”, “”, 0, args1)
Case “Down”
loXDispatchHelper.executeDispatch(loXDispatchProvider, “.uno:GoDown”, “”, 0, args1)
Case “Left”
loXDispatchHelper.executeDispatch(loXDispatchProvider, “.uno:GoLeft”, “”, 0, args1)
Case “Right”
loXDispatchHelper.executeDispatch(loXDispatchProvider, “.uno:GoRight”, “”, 0, args1)
End Select
Next
End Sub