Solved

dsoframer.ocx control  in vb.net2008

Posted on 2011-09-26
3
665 Views
Last Modified: 2012-05-12
I am using dsoframer.ocx control to load word documents. And I am scrolling doc by firing page down command using vb.net 2008 application (through sendkeys.send).
My problem is when I am firing page down command, after reaching to last page, how to know that word doc reached to last page so that I can execute clt+ Home command to reach again to first page.

0
Comment
Question by:ajayvegesna02
  • 2
3 Comments
 
LVL 40
ID: 36600226
Sendkeys is a very limited (and risky) way of working with another application. Since it does not provide feedback, you have no way to control what is happening in the applications.

You have to look in your ocx documentation to know if it has a feature to do what you want.

Or learn to control Word through OLE automation. You then would have a direct contact with Word and would be able to do almost anything you want. It would require more code however.
0
 

Author Comment

by:ajayvegesna02
ID: 36708337
can you provide me examples on this using vb.net 2008
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 36712152
Sorry for the delay, pretty busy these days and I haven't work on that for a while.

Here it is.
Imports Microsoft.Office.Interop.Word

Module Module1

   Public Sub WorkWithWord()

      Dim app As New Application
      Dim doc As Document
      Dim lastPage As Integer

      doc = app.Documents.Open("Your document.doc")

      With app.Selection

         .EndKey(WdUnits.wdStory)
         lastPage = CInt(.Information(WdInformation.wdActiveEndPageNumber))
         .HomeKey(WdUnits.wdStory)

         app.Visible = True

         While CInt(.Information(WdInformation.wdActiveEndPageNumber)) < lastPage

            .MoveDown(WdUnits.wdScreen, Count:=1)

         End While

         MessageBox.Show("You are at the end of the document. Press OK to go back to the top.")

         .HomeKey(WdUnits.wdStory)

      End With

      MessageBox.Show("You are back at the beginning. Press OK to get out of the application")

      app.Quit()

   End Sub

End Module

Open in new window

Ask if you have questions.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now