?
Solved

Open .Doc File in vb6 textbox or rich textbox with formating....

Posted on 2005-03-28
13
Medium Priority
?
879 Views
Last Modified: 2008-01-09
Here is the thing

I want to do the fellowing.

open a word doc file with formating or an html page with formating into a text box or rich text box
and then create a flash file based on the text given that is like a flash book
is should be able to output a swf and a exe.

this is my goal i can handle the flash part but i need help in the programming.

please try to avoid activex controls or other types and don't want those word.open app thing

keep the depedencies to a minimum please thx alot
0
Comment
Question by:Ethen_hunt
[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
  • 7
  • 4
  • 2
13 Comments
 
LVL 11

Expert Comment

by:bingie
ID: 13649485
Use the webbrowser component. From the IDE, CTRL+T select "Microsoft Internet Controls" and add it to your form. Then just naviagte to your document:

Webbrowser1.Navigate2 "c:\myDoc.doc" or for the webpage
Webbrowser1.navigate2 "www.yourwebpage.com"
0
 

Author Comment

by:Ethen_hunt
ID: 13651024
well that opens the word application or ask me to save the file

i want to open it in a text box m8

thx for your reply tho.
0
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 13653347
You can use the RichTextBox control to do it for .RTF files -- RichTextBox1.LoadFile "file.rtf" -- but I don't think it will work for .doc files...

I think bingie's got the best option -- the Open/Save dialogue you get is a security setting that you may be able to turn off...

J.
0
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.

 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 13653368
And if you want any kind of Word functionality, without using the Word object, I think you'll need a spare $1300 (ish) for the tools at Aspose (http://www.aspose.net)

J.
0
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 13653374
Either that, or you'll need to parse the entire file format yourself...

J.
0
 
LVL 11

Expert Comment

by:bingie
ID: 13656282
I have yet to find a better solution then using the webbrowser component, since the rtb doesn't really work for this - it somtimes messes up the formatting since a word doc is compleatly different from a .txt or .rtf.

Why are you opposed to that?
0
 

Author Comment

by:Ethen_hunt
ID: 13667042
well i am not i need to get the text with the formating intact so i can change few things and process it. if you can provide any code that will disable the security thing for a temp time i might go that way then. :D
0
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 13967387
>>  if you can provide any code that will disable the security thing for a temp time

OK, the theory is:

      On file load:
      (1.)  Scan the HKEY_CLASSES_ROOT registry branch for the '.doc' subbranch
      (2.)  Determine the associated class from the '(default)' key
      (3.)  Scan the HKCR branch again, for the associated class' subbranch
      (4.)  Modify the 'EditFlags' key so that the third flag is 01, not 00
      (5.)  Navigate to the .doc file in the Webbrowser control
      (6.)  Modify the 'EditFlags' key so that the third flag is whatever it was before.

When I've written and tested it, I post it here...

J.
0
 
LVL 16

Accepted Solution

by:
jimbobmcgee earned 500 total points
ID: 13968655
OK, using the Complete Registry Class from http://www.vbaccelerator.com/home/VB/Code/Libraries/Registry_and_Ini_Files/Complete_Registry_Control/article.asp:

    Private Sub CommandButton1_Click()
   
        Dim oReg As New cRegistry
        Dim szDocClass As String
        Dim a_byEditFlags() As Byte
        Dim byOldFlag As Byte
   
        '(1.)  Scan the HKEY_CLASSES_ROOT registry branch for the '.doc' subbranch
        oReg.ClassKey = HKEY_CLASSES_ROOT
        oReg.SectionKey = ".doc"
       
        '(2.)  Determine the associated class from the '(default)' key
        oReg.ValueKey = ""
        oReg.ValueType = REG_SZ
        szDocClass = oReg.Value
       
        '(3.)  Scan the HKCR branch again, for the associated class' subbranch
        oReg.SectionKey = szDocClass
        oReg.ValueKey = "EditFlags"
        oReg.ValueType = REG_BINARY
        a_byEditFlags() = oReg.Value
        ReDim Preserve a_byEditFlags(UBound(a_byEditFlags()) - 1)
       
        '(4.)  Modify the 'EditFlags' key so that the third flag is 01, not 00
        byOldFlag = a_byEditFlags(2)
        a_byEditFlags(2) = 1
        oReg.Value = a_byEditFlags()
       
        '(5.)  Navigate to the .doc file in the Webbrowser control
        WebBrowser1.Navigate2 "file:///d:/test.doc"
        Do Until WebBrowser1.ReadyState = READYSTATE_COMPLETE
            DoEvents
        Loop
       
        '(6.)  Modify the 'EditFlags' key so that the third flag is whatever it was before.
        a_byEditFlags(2) = byOldFlag
        oReg.Value = a_byEditFlags()
       
        Set oReg = Nothing
       
    End Sub

HTH

J.
0
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 13968666
If that doesn't work then you're going to need to use the Word object...

J.
0
 

Author Comment

by:Ethen_hunt
ID: 14017019
well thx alot for the help but i can't use a 3rd party code :(

i am haveing a problem in one thing and if you help me i will give you the full points.

i have a word doc in which i want to take a name form the access database and put in a position and then from vb6 give a print command after displaying the printing dialog box

basicly i want a front sheet  to be printed if you know what i mean if not reply and i will try my best. :D

thx once again.
0
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 14126543
Thanks for the points.  Why no third party code?  It's just a .bas file that you drop in to your app.  You don't have to install it, or anything.  If third-party code is really a problem, do a Google search for the API required to read/write registry values, then replicate it.

As for your front sheet, how about creating a page at the beginning of the document, with some form fields, then using Mail Merge or ADO to populate them...

J.
0
 

Author Comment

by:Ethen_hunt
ID: 14137561
you mean a form in MS word ? and if that is possible can i print the form directly from vb?
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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

801 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