Solved

dsoframer.ocx control  in vb.net2008

Posted on 2011-09-26
3
653 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

929 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

13 Experts available now in Live!

Get 1:1 Help Now