Solved

Adding Scroll Bars To Word in OLE Container

Posted on 2001-07-14
4
1,444 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
  • 3
4 Comments
 

Expert Comment

by:terry_mtw
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
hihi,

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…
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…

763 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

9 Experts available now in Live!

Get 1:1 Help Now