Solved

dsoframer.ocx control  in vb.net2008

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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