Solved

Adding Scroll Bars To Word in OLE Container

Posted on 2001-07-14
4
1,568 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month8 days, 1 hour left to enroll

617 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