Scroll Bars (1 Viewer)

jason120au

Member
Joined
Nov 26, 2003
Messages
42
Gender
Male
HSC
2004
I have a Word Document which has been inserted into a form using an Active X control, how do I add scroll bars to the document?
 

Winston

Active Member
Joined
Aug 30, 2002
Messages
6,128
Gender
Undisclosed
HSC
2003
What language, what active X control is it...
 

jason120au

Member
Joined
Nov 26, 2003
Messages
42
Gender
Male
HSC
2004
In the insertable objects menu, ie in VB go to Projects, Components, and click on the insertable components tab, Word is listed, and you can add a word document to a form using it.
 

raymes

Member
Joined
Jan 21, 2004
Messages
116
Location
Sydney
Gender
Male
HSC
2004
seems like a pretty crappy and useless control to me. what specific purpose does it have in your project? there is most probably a better way of doing what you want to do
 

jason120au

Member
Joined
Nov 26, 2003
Messages
42
Gender
Male
HSC
2004
For my group project, we are doing a tour of the school, we have managed to get a document which has been distrubuted by the school that lists all the staff and their departments etc. I have added that document using the Active X Controls, but I can't get a scroll bar to work, please refer to the following pic that is attached. I have added the verticle scroll bar on the right, but I am unable to get it to scroll down the document.
 

Winston

Active Member
Joined
Aug 30, 2002
Messages
6,128
Gender
Undisclosed
HSC
2003
Ummmm so you're loading a doc file using that Active X control?
 

raymes

Member
Joined
Jan 21, 2004
Messages
116
Location
Sydney
Gender
Male
HSC
2004
see the thing is that its probably not possible to add scroll bars with this control....not in any simple way anyway. the control you are talking about is, for all practical purposes, is useless. what it pretty much is, is a way to put microsoft word into your application but no way to interface it with your application. throw these types of controls away and never think of them again.

what you are really looking for is the rich text box control.

project>components>controls tab (default) > check the microsoft rich text box control

firstly save your document in microsoft word as a .rtf document.

now in your project set the filename property of the rtbox to the .rtf file. then you can set the scrollbar propertys to your liking ;)

if you want to allow the user to format the text themselves (e.g. select a font, colour, size, etc. like you can do in microsoft word) it gets a little more complicated but nothing u cant find from checking out some examples on planetsourcecode.com or similar sites. opening, printing and saving documents from an rt box is also extremely easy but im not going into that now. it seems as though you only wanted to display a file anyway :p

hope this helps, good luck
 

jason120au

Member
Joined
Nov 26, 2003
Messages
42
Gender
Male
HSC
2004
would someone be able to show me the Scroll function stuff, as I don't have MSDN on this computer, faulty disc and the MSDN Library online doesn't have that function listed.
 
Last edited:

raymes

Member
Joined
Jan 21, 2004
Messages
116
Location
Sydney
Gender
Male
HSC
2004
the actual scollbar control in visual basic isnt going to scroll through other controls for you. different controls have their own scroll bars built in. for example, in a text box, you can set it to have scroll bars in its property's (the place where u set its name, text, etc.). this is the same with the rich text box i was blabbering on about before
 

jason120au

Member
Joined
Nov 26, 2003
Messages
42
Gender
Male
HSC
2004
I've got the scroll bar to work using the properties thingy, but it stuffs the formating of the document, what commands can I use to get a command button to load the document in say Microsoft Word.
 

hornetfig

Member
Joined
Jun 27, 2004
Messages
65
Location
Sydney. oddly
Gender
Male
HSC
2003
ewww OLE.

Word in an OLE container is not terribly pretty. You need the Word VBA documentation with you to do anything. For example, this code conducted a word count on the contents of a rich text box called rtxMain:

Code:
Private Sub DoWordCount()
  Dim objW As Object
  Dim oDoc As Object
  
  On Error GoTo Kill

  Set objW = CreateObject("Word.Application")

  objW.Visible = False
  Set oDoc = objW.Documents.Add()

  objW.Selection.TypeText (rtxMain.Text)

  Dim Temp As Object
  'dialog 228 being the word count dialog
  Set Temp = objW.Dialogs(228)
  Temp.Show
  Set Temp = Nothing
  objW.Visible = False

  'Close Word
  objW.DisplayAlerts = False
  oDoc.Close False
Kill:
  objW.Quit False

  Set oDoc = Nothing
  Set objW = Nothing
End Sub

Anyhow, for your problem, it's probably something to do with the OLE container not having focus properly. I'm not sure what you'd do about it though...

launching the document is a proper Word window would be much simpler, see http://www.boredofstudies.org/community/showthread.php?t=35596 or innumerable other threads on the ShellExecute() API function.
 

jason120au

Member
Joined
Nov 26, 2003
Messages
42
Gender
Male
HSC
2004
Code:
Private Sub Command2_Click()
Dim RetVal
RetVal = Shell("C:\Program Files\Microsoft Office\Office10\WINWORD.EXE", 1)   ' Run Calculator.
End Sub
Thats the code of got that will load Microsoft Word which works, but how do I actually get it to load MS Word with the respective document.
 

jason120au

Member
Joined
Nov 26, 2003
Messages
42
Gender
Male
HSC
2004
Thank you all for your help, I found the file associations code etc to get a command button to open up a file in a program a bit confusing so I have decided to stick with the Rich Text thingy with its dodgy formating, it doesn't look too bad but it would look better if it didn't stuff it up, but beggers can't be choosers.
 

raymes

Member
Joined
Jan 21, 2004
Messages
116
Location
Sydney
Gender
Male
HSC
2004
the command button code is actually pretty simple...but anyway

if you want to get the formatting right in the rich text box, edit the .rtf file with wordpad ;)
you will probably have to take out a lot of the fancy formatting features in word (such as the ability to place a picture anywhere on the page)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top