Question : Cursor position in a word document created by vb.net

Iam using vb.net to write to a word document that has four columns. Some text I have to put it in a text box.
Problem:

I want to know the position of the cursor as i am writing such that I can position the the text box in the right place. (I want to position the left and top values of the box depending on the position of the cursor)

can any one help me out.

regards

Anthony Matovu

Answer : Cursor position in a word document created by vb.net

You can make the textbox height adjust automatically to fit the text.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim wdApp As New Word.Application()
        Dim wdDoc As Word.Document
        Dim rng As Word.Range
        Dim tb As Word.Shape

        wdApp = CreateObject("Word.Application")
        wdApp.Visible = True
        wdDoc = wdApp.Documents.Add
        wdDoc.Range.Text = "Some text." & vbCr & "Some more Text"
        rng = wdDoc.Bookmarks.Item("\EndOfDoc").Range
        tb = wdDoc.Shapes.AddTextbox(1, 30, 100, 200, 10, rng)
        tb.TextFrame.TextRange.Text = "Uganda Meat Industries Ltd " & vbCr & "Old Portbell Road" & vbCr & "P.O.Box 180, Kampala" & vbCr & "Tel..........................320940" & vbCr & "Fax..........................230989"
        tb.TextFrame.AutoSize = True
    End Sub
Random Solutions  
 
programming4us programming4us