Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Adding Scroll Bars To Word in OLE Container

Posted on 2001-07-14
4
Medium Priority
?
1,629 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 800 total points
ID: 6297095
hihi,

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

715 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