Results 1 to 15 of 15

Thread: how to open word(microsoft word) to richtextbox in vb.net?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    19

    how to open word(microsoft word) to richtextbox in vb.net?

    how to open word(microsoft word) to richtextbox in vb.net? i just know use vb.net to open word but cannot import to richtextbox

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: how to open word(microsoft word) to richtextbox in vb.net?

    A RichTextBox only can show plain text and RichText. A Word document is a word document, not a richtext document so you can't open a Word document inside of a RichTextBox unless you convert it to Rtf first.

    If you are dead set on getting a word document to work in a richtextbox, you're probably going to have to create your own RichTextBox (inheriting the System.Windows.Forms.RichTextBox) and then read in the Word document, do your own parsing and convert it to Rtf. You won't be able to show all of the advanced features that way.

    It's either that or you're creating your own TextBox from scratch and drawing everything. Again, you'd need to parse the Word Document.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    19

    Re: how to open word(microsoft word) to richtextbox in vb.net?

    How Word document convert it to Rtf?

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: how to open word(microsoft word) to richtextbox in vb.net?

    Do a .SaveAs and pass the parameter rtf parameter.
    VB Code:
    1. '...
    2. '...
    3. oDoc.SaveAs(FileName:="C:\Test.rtf", FileFormat:=Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatRTF)
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: how to open word(microsoft word) to richtextbox in vb.net?

    Quote Originally Posted by BradleyOng83
    How Word document convert it to Rtf?
    Well, you have two options. Save it as an Rtf from within Word (As RobDog's code does), or you do some heavy research into the Doc format and write your own parser to parse it and then save as an Rtf. The former is easy but the user has to have Word on their machine. The latter is very difficult but you wouldn't need Word.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: how to open word(microsoft word) to richtextbox in vb.net?

    Since its a proprietary fileformat, I doubt you will be able to parse it without having Word installed on the system. So since you need Word, might as well take advantage of it.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: how to open word(microsoft word) to richtextbox in vb.net?

    Quote Originally Posted by RobDog888
    Since its a proprietary fileformat, I doubt you will be able to parse it without having Word installed on the system. So since you need Word, might as well take advantage of it.
    It's proprietary but that doesn't mean Word has to be installed. No part of any Document is saved to the Word program, therefore the Word Document has everything needed. You just have to find a way to figure out what every part means with little to no documentation. You can build your own Parser.

    OpenOffice.org and KOffice both can read Word documents. They run on Linux so they definately don't require Word to be installed.

    So while it is an option to parse a Word document and display it without Word, it's incredibly difficult. OpenOffice has tons and tons of developers in IBM, Sun, and regular OO developers. It's definitely a huge task for one person.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: how to open word(microsoft word) to richtextbox in vb.net?

    True, but thats why it wouldnt be a real solution as I wouldnt want to even try it. I dont have that kind of time left in my life.

    Ps, you need to update your avatar from vBulletin 2.0 to 3.0
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: how to open word(microsoft word) to richtextbox in vb.net?

    Quote Originally Posted by RobDog888
    True, but thats why it wouldnt be a real solution as I wouldnt want to even try it. I dont have that kind of time left in my life.
    Hey! It's a real solution

    Though it isn't practical at all.
    Quote Originally Posted by RobDog888

    Ps, you need to update your avatar from vBulletin 2.0 to 3.0
    But vBull 3 doesn't have an image. It's just text

    Though in my preferences I told it to reference the URL for the LogOut button and didn't upload it myself (or at least I thought I did).
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  10. #10
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: how to open word(microsoft word) to richtextbox in vb.net?

    why not use the dsoframer.ocx and use it's read/write doc files methods in conjunction with the richtextbox

    microsoft word's interface is one big glorified richtextbox...
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: how to open word(microsoft word) to richtextbox in vb.net?

    Is the "dsoframer.ocx" a third party control or a MS one? Also, is it free?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: how to open word(microsoft word) to richtextbox in vb.net?

    Quote Originally Posted by RobDog888
    Is the "dsoframer.ocx" a third party control or a MS one? Also, is it free?

    yes and yes
    i'll upload it for ya here cause i dont have a link to it on MS's site
    Last edited by JuggaloBrotha; Jun 30th, 2010 at 03:00 PM.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  13. #13
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: how to open word(microsoft word) to richtextbox in vb.net?

    Quote Originally Posted by JuggaloBrotha
    yes and yes
    i'll upload it for ya here cause i dont have a link to it on MS's site
    So I take it it's an MS control (the first question wasn't a yes or no so it's hard to tell what you were saying yes to)?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: how to open word(microsoft word) to richtextbox in vb.net?

    If you check its properties you can see its "UNSUPPORTED BY MICROSOFT" and also signed by Microsoft. So its probably a Beta and/or free. I'll look if its still available as it was signed ~ a year ago.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: how to open word(microsoft word) to richtextbox in vb.net?

    Its True. but only supports Office 2000 and 2002 (XP).

    Here is the link to it. Its a VC++ ocx for use in Visual Basic but doesnt say if its .NET or VB6. It does mention C# so maybe...


    http://support.microsoft.com/default...b;en-us;311765
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width