Wrox Programmer Forums
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 13th, 2004, 04:12 PM
Registered User
 
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pulling Fonts from Word

Sorry if this is in the wrong forum. I have the following problem:
I have an app that generates plain-text reports and then pushes the plain text into Word to leverage styles and formatting and other Word nice-ities. Now the client would like to be able to change the look of text from the application. My plan is to define Styles in their Word template, pull them back into the app, and use their attributes to format text in a rich text box. Obviously there are a lot of tricky things to deal with here, but the one I am presently stuck on is how to assign the properties from the Word style to the text in the rich text box? Here's what I have:

            Dim appword As New Word.ApplicationClass
            appword.Documents.Add()
            Dim docword As Word.Document = appword.ActiveDocument
            Dim wdstyle As Word.Styles = docword.Styles
            Dim wdfont As Word.Font
            Try
                wdfont = wdstyle.Item("Heading 1").Font
               *RichTextBox1.SelectionFont = wdfont

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

            docword.Close(False)
            appword.Quit()

The idea is that the user puts text in the rich text box, selects it, right clicks, and picks the style from the context menu. Then format the text using the coinciding style from the Word template. Right now it always throws "Specified Cast is not valid" on the line with the asterisk. Basically I'm looking for a way to convert a Word.Font into a System.Drawing.Font. Any help is greatly appreciated. I don't need working code or anything, just to be pointed in the right direction.

Thanks

Mike





Similar Threads
Thread Thread Starter Forum Replies Last Post
Wordml fonts johnlaw83 XSLT 1 June 19th, 2007 09:39 AM
Word has no Fonts BrianWren Word VBA 1 September 8th, 2006 12:33 PM
pulling data from webpage zeeonline XSLT 3 July 27th, 2006 03:04 PM
Iterating Fonts Ron Howerton Visual Basic 2005 Basics 9 May 31st, 2006 07:15 PM
only pulling out 1 record Adam H-W Classic ASP Basics 4 April 12th, 2004 07:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.