Solved

OLE object scrolling

Posted on 1998-07-14
14
699 Views
Last Modified: 2013-11-25
I have an OLE object that containes a linked Excel spreadsheet (OLE1.sourcedoc = C:\stoplight.xls).  When I display the form containing the OLE object my spreadsheet is loaded just fine but I am unable to scroll down to see all the data.  All I want to do is scroll the data in the OLE window.  I want my program form to remain visible.  I tried to add a vscroll control to my form but it scrolls the OLE object window off the screen.  I just cant seem to figure out how to anchor the OLE window and scrool the data.
0
Comment
Question by:clarwc
  • 6
  • 5
  • 2
  • +1
14 Comments
 
LVL 6

Expert Comment

by:anthonyc
ID: 1465699
You can set it up by:

1)  Setting the OLE control to autosize, making it the entire size of the document.

2)  Add a Vertical (and horizontal) scrollbar, both going from 0 to the height (or width) of the OLE control

3)  On the change event of the vertical (or horizontal) scrollbar, put code like this

OLE1.move -1 * hscroll1.value, -1 * vscroll1.value

which will move the control around.. or give the appearance of that anyway.  Set the LargeChange value to the height/width of the form.

Anthony
0
 

Author Comment

by:clarwc
ID: 1465700
Anthonyc

Thanks for the suggestion.  I am VERY new to programming and self taught too....

The suggestion you gave won't work for me because I have controls on the bottom of the form that need to be available.  for this reason I need to leave the window at it's current height and scroll the data within the window...

Any Ideas???
0
 
LVL 6

Expert Comment

by:anthonyc
ID: 1465701
yes.

Put the OLE control inside a picture box.  A Flat picturebox that has the same backcolor as the form.  Then do the same things I mentioned above, but using picturebox dimensions.  You can size the picturebox to any size you'd like.

Anthony
0
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

Author Comment

by:clarwc
ID: 1465702
I need just to scrool up and down in the box.  I tried to use

OLE1.move -1 vscroll1.value

But that scrolled it side to side.  I will try the picturebox but can you tell me the code for moving the object up and down???

Thanks...

Warren
0
 

Author Comment

by:clarwc
ID: 1465703
What do you mean by Put the OLE control inside a picture box.  

Do I set a property of the picture box?  How do I get the OLE object inside the picturebox?  Sorry if these are very basic kinds of questions.



0
 

Author Comment

by:clarwc
ID: 1465704
Got the picture box and OLE working and it looks good but I can't get the scroll to go up and down....
0
 
LVL 1

Expert Comment

by:Jason_G
ID: 1465705
Hi clarwc,
It seems you have a pesky little problem on your hands.  I found out how to do implement scrollbars when embedding a Word document, as shown below.

1. Start Visual Basic; Form1 is created by default.

2. Add an OLE container control to Form1 (Ole1 is the default name for the control).

3. The insert object dialog box should appear after you draw the OLE container control on the form. Choose Create from the File option, and choose an existing Word .DOC file that is more than a page in length. The "Link" and "Display As Icon" check boxes should not be selected. Choose the OK button when you are done; the document should now be embedded in the OLE container control.

4. Add a VScrollBar button to Form1 (SpinButton1 is the default name of the control).

5. Place the following code in the UpDown1_DownClick event:

Private Sub UpDown1_DownClick()
If OLE1.AppIsRunning Then
OLE1.Object.Application.WordBasic.VLine -1
         Else
         OLE1.Action = 7        'Activate
End If
End Sub

6. Place the following code in the UpDown1_UpClick event.

Private Sub UpDown1_UpClick()
If OLE1.AppIsRunning Then
OLE1.Object.Application.WordBasic.VLine 1
     Else
         OLE1.Action = 7           'Activate
End If
End Sub

7. Save the project.

8. Run the application.

9. Double-click the OLE control to activate the Word .DOC object for visual editing.

10.Press the VScrollBar button to scroll up and down the document.

I know you wanted this for Excel, but I haven't had time to look into it yet.  I'm sure it is nearly identical, and if I find the solution for it I will send you the code, however, this should put you on the right track.

I hope this helps.

Sincerely,
Jason

Jason Gorman (jason_gorman@scholars.com)
Learning Advisor, scholars.com
Microsoft Authorized Technical Education Center
Novell Authorized Online Training Provider
http://scholars.com
0
 
LVL 1

Expert Comment

by:Jason_G
ID: 1465706
Hi clarwc,
Sorry, a little mistake in step 4, where you see spinbutton1, replace that with UpDown1.  I had to convert the code from VB4.0 which used spinbuttons to VB5.0, and got a little mixed up when writing it down.

Good luck.

Sincerely,
Jason

Jason Gorman (jason_gorman@scholars.com)
Learning Advisor, scholars.com
Microsoft Authorized Technical Education Center
Novell Authorized Online Training Provider
http://scholars.com
0
 

Author Comment

by:clarwc
ID: 1465707
Jason,

Thanks for the code...I would like to figure out a way to split the points between you and Anthony.....Any suggestions???
0
 
LVL 1

Expert Comment

by:Jason_G
ID: 1465708
Hi clarwc,
Well, I've had this happen to me before where a user wants to split points between myself and another expert, and usually there is a lady who does customer service for Experts.com who has the username linda.  I'm not exactly sure how to contact her, but I think she will contact you.

All she did was post questions to each of us, with the subject, question for Jason_G and question for OtherExpert.

If you make a post for no points requesting her assistance she will help you, although she may contact you just from this post.

Also, since I've never posted a question, I'm not sure exactly how it works, but you could always withdraw your points, and post 2 new questions in the manner I mentioned above, and then award the points to us when we reply.

I hope I helped.

Sincerely,
Jason

Jason Gorman (jason_gorman@scholars.com)
Learning Advisor, scholars.com
Microsoft Authorized Technical Education Center
Novell Authorized Online Training Provider
http://scholars.com
0
 
LVL 1

Expert Comment

by:Jason_G
ID: 1465709
Hi clarwc,
I found what you need to do, you simply go here, and post that you want to split your points between 2 experts.
http://www.experts-exchange.com/browsing/experts-exchange/

I hope this helps.

Also, thank you for the points.

Sincerely,
Jason

Jason Gorman (jason_gorman@scholars.com)
Learning Advisor, scholars.com
Microsoft Authorized Technical Education Center
Novell Authorized Online Training Provider
http://scholars.com
0
 
LVL 7

Expert Comment

by:linda101698
ID: 1465710
On this question, I suggest that you have JasonG post an answer and grade the question awarding him the points.  I'll post another question to award anthonyc some points.

anthonyc,
Look for the question in the unanswered questions directed to you.

Jason_G,
Post an answer so the question can be graded.

Linda Gardner
Customer Service @ Experts Exchange
0
 
LVL 1

Accepted Solution

by:
Jason_G earned 200 total points
ID: 1465711
Hi Linda and clarwc,
Just responding to your comments, to receive my points.

Thanks,

Sincerely,
Jason

Jason Gorman (jason_gorman@scholars.com)
Learning Advisor, scholars.com
Microsoft Authorized Technical Education Center
Novell Authorized Online Training Provider
http://scholars.com
0
 

Author Comment

by:clarwc
ID: 1465712
Thanks for the help...

sorry it took so long for me to award the points...

Warren
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

803 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