Blink a cursor in the selected bookmark

N

Nazim

I am integrating a word document in vb.net. I have successfully done it. What
i want is. I have set book marks in word template. Whenever i click a button,
it should go to the bookmark and write a text over there. Problem is, it
nevers show cursor position there but take it to the bookmark. I want to show
my cursor blinking on the selected bookmark. Kindly help me in regarding this
 
N

Nazim

On load event
-------------------
Dim filNm As String
Friend WithEvents objWinWordControl As WinWordControl.WinWordControl

filNm = openFileDialog1.FileName
objWinWordControl.LoadDocument(filNm)

" WinWordControl.WinWordControl ", It is a control i found it on internet.
Below is the link where i found this control
http://www.codeproject.com/dotnet/WordInDotnet.asp

I have integrated this control in my vb.net (desktop) application. I load
the word template document in which there are several Bookmarks defined named
section1, section2, section3, section4.


On click event of a button, i want to paste a particular text inside the
word "Section1" on the particular bookmark.



"Section 1 Button1" Section1
Checkbox 1 ------------------
Checkbox 2


UpOn Clicking on Section 1 Button1, it should display cursor on the right
pane under section1 header. What it does actually, never display the cursor
but the bookmark clause takes the cursor there (But cursor does not appear
visually.) All i want to do is to show the cursor there blinking whenever i
click on Button 1 on right pane.



Dim wd As New Word.Document
Dim wa As New Word.Application

wd = objWinWordControl.document
wa = wd.Application


wd.Bookmarks.Item("Section1").Select() 'This line will take
the focus to the Section as it is a bookmark
'alreaded added in the word template, but it does not show
cursor 'blinking
over there.



On Checkbox click i have set the code to write the text under the
section1 on the right pane which is as below.

wd = objWinWordControl.document
wa = wd.Application

wa.Selection.TypeParagraph()
wa.Selection.TypeText("This is a paragraph related to Section1")


All i wanted to blink my cursor under the relevant header when i click on
button"Section1 Button1" in vb.net program

Thanks in advance.
 
D

Dave Lett

Hi Nazim,

Try something like this:


Dim wd As New Word.Document
Dim wa As New Word.Application

Dim oRng as Range

wd = objWinWordControl.document
wa = wd.Application

Set oRng = wd.Bookmarks("Section1").Range
oRng.Collapse Direction:=wdCollapseStart
oRng.Select

HTH,
Dave
 
N

Nazim

Thank you Dave for your prompt email. I have used this code. But the problem
still persists. It takes you to the bookmark but again No visual Cursor
appearance is there. I want the Cursor to display visually inorder to make it
User handy. Although this code places the cursor logically there. But it does
not appear there. Kindly look into it. Thanks in advance.
 
D

Dave Lett

Hi Nazim,

This works in my environment (Windows XP, Word 2003). I imagine that it
should work in other environments.

Dave
 
N

Nazim

Thanks Dave, I am using Vb.net with windows XP installed in my PC. i have
office 2003 installed. Problem is i dont get the cursor appear blinking or
standing there. But i do get it logically as whenever i wwrite things to
bookmark it documents there and write the text from there. Kindly help me in
regarding it.

If you can do a favour. I have mentioned the link of the word control. And
use it in vb.net environment and put a button there which on click will
display the focus on the particular bookmark. can you please send this sample
applciation to me. I will be very thankful to you...
Many many thanks in advance.
Regards,
Nazim
 
N

Nazim

My email id is (e-mail address removed)

Nazim said:
Thanks Dave, I am using Vb.net with windows XP installed in my PC. i have
office 2003 installed. Problem is i dont get the cursor appear blinking or
standing there. But i do get it logically as whenever i wwrite things to
bookmark it documents there and write the text from there. Kindly help me in
regarding it.

If you can do a favour. I have mentioned the link of the word control. And
use it in vb.net environment and put a button there which on click will
display the focus on the particular bookmark. can you please send this sample
applciation to me. I will be very thankful to you...
Many many thanks in advance.
Regards,
Nazim
 
N

Nazim

Thank you very much for your help. It is working now, my word has problems.
Thanks once again. I am stuck in one more problem in this program if you can
sort it out.

I open the word template document using my vb.net program. the document
contains 6-8 headings. Whenever i click on button text is writted under the
heading where cursor is blinking. Problem i need to fix my recommendation
section always at the top of the word page. i.e. Regardless of how many para
we add in the document. Conclusion and recommendation should stand at the
top. Please if you can help me out.

thankss..

Headers

Protection

Income

Recommendation section
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top