Solved

dsoframer.ocx control  in vb.net2008

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 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