Solved

Adding Scroll Bars To Word in OLE Container

Posted on 2001-07-14
4
1,540 Views
Last Modified: 2012-05-04
I'm using VB6 against an SQL Server 7 database and am trying to do the following:

I'm using an OLE container to display MS Word documents on a form.
When the user double-clicks on the container, I open the MSWord document in its own window so the user can edit it there.
However, the users would like to have the ability to scroll in the container window.
I guess this can't be done directly since scroll bars are not a property of the OLE object.
I'm trying to find info on this and I found what may be an option:
Someone suggested the webbrowser control which was added with sp4.
With this control, many of the word features can be used inside the container.
This may be too much for what I want to do, though.
Remember, I just need to give the user the ability to scroll up and down in a word document.
Does anyone have any experience with the webbrowser control and word documents?
Can anyone suggest any alternatives or suggestions for what I want to do?

Thanks in advance.
John
0
Comment
Question by:jtrapat1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 

Expert Comment

by:terry_mtw
ID: 6288287
yep, this is not supply scroll bars,  so, if you want to scroll the document, you should use spin button or image-control that cannot receive the focus.

Sub SpinButton1_SpinDown()
    If OLE1.AppIsRunning Then
        OLE1.object.Application.WordBasic.vline 1
    Else
        OLE1.Action = 7     ' Activate
    End If
End Sub

Private Sub SpinButton1_SpinUp()
    If OLE1.AppIsRunning Then
        OLE1.object.Application.WordBasic.vline -1
    Else
        OLE1.Action = 7     ' Activate
    End If
End Sub
0
 

Author Comment

by:jtrapat1
ID: 6290455
terry,

thanks for the info.
can you just let me know one more thing?
When you first add an OLE object to a form, you are prompted if you want to create a link to an existing word document (or other file).
When I choose to link to an existing word doc, the code for the scroll bars above works.
However, if I try to pass the OLE object a filename, and have the OLE object link to that document on the fly, it doesn't work.
If I then move the scroll bars, it simply opens up MSWord with that document inside.

here's the code I tried:
    If Dir(FileName) <> "" Then
        OLE1.CreateLink FileName
    Else
        OLE1.CreateLink "z:\FILE\template.doc"      
    End If
   
Is there a way around this?

Thanks
0
 

Expert Comment

by:terry_mtw
ID: 6297089
hihi,
if you want to embed a document to your ole container, you can use OLE1.CreateEmbed "filename or path". Then, add OLE1.DoVerb -1 comment to activate and edit the document.

Following is the example to embed the Hi.doc in c directory and scroll the ole container.
Hope this can help you.....^^

start vb and standard form, and add ole1 and don't insert object. then add command1 and timer1 and name it OleTimer.

Option Explicit

Dim oleActive As Boolean
Dim oleFileName As String

Private Sub form_load()
    oleActive = False
End Sub

Private Sub OleTimer_Timer()
    If oleActive Then
    With OLE1.object
        .ActiveWindow.DisplayVerticalScrollBar = True
        .ActiveWindow.DisplayHorizontalScrollBar = True
    End With
    End If
End Sub

Private Sub Command1_Click()
    OLE1.CreateEmbed "c:\HI Terry1.doc"
    OLE1.DoVerb -1
    OLE1.SizeMode = 1
    oleActive = True
End Sub


0
 

Accepted Solution

by:
terry_mtw earned 200 total points
ID: 6297095
hihi,

sorry I forgot something, change properties of OleTimer's Interval from 0 to 1.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

751 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