Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB.NET
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 20th, 2007, 07:39 AM
Registered User
 
Join Date: Oct 2006
Location: Middlesbrough, Cleveland, United Kingdom.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Word Parsing - VB.net

Hello again,

I am wanting to read a certain style of heading from a Word document, once I find it I want to export it into a CSV file, or XML document.

When I am running the programme and I check the output file theres nothing in it can anybody help?

Below is the code which I am using.

Imports System.IO
Imports Word
Imports WordAutomation

Public Class Form1
    Public wdoc As Word.Document
    Public wapp As Word.Application

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Declarations
        Dim doc As New Word.Document
        Dim wordApp As New Word.Application
        Dim arguments As [String]() = Environment.GetCommandLineArgs()
        Dim fsStream As New FileStream("a:\test.csv", FileMode.Append, FileAccess.Write)
        Dim swWriter As New StreamWriter(fsStream)

        doc = wordApp.Documents.Open("c:\temp\MCG1115A15")
        wordApp.Visible = True
        wordApp.Selection.EndKey(Word.WdUnits.wdStory)
        wordApp.Selection.HomeKey(Word.WdUnits.wdStory, Word.WdKey.wdKeyShift)

        'Variables
        Dim count As Integer
        count = wordApp.Selection.Range.ComputeStatistics(Word.WdS tatistic.wdStatisticLines)

        'Variables
        Dim i As Integer

        For i = 0 To 2
            wordApp.Selection.HomeKey(Word.WdUnits.wdLine)

            If wordApp.Selection.Range.Style.ToString = "Test Heading 2" Then
                swWriter.Write("Test Heading 2", wordApp.Selection.Range.Style.ToString)
                swWriter.Close()
            End If
            wordApp.Selection.MoveDown(Word.WdUnits.wdLine, 1)
        Next
    End Sub
End Class


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.Net Word Automation deboe Pro Visual Basic 2005 0 November 26th, 2007 09:57 PM
formatting of a word document with vb.net krmilburn General .NET 0 April 18th, 2006 06:47 AM
Reading MS WORD Document by VB.Net ocarroll General .NET 0 March 31st, 2006 02:17 AM
VBA Word is very slow with vb.net preeti01 VB How-To 4 May 5th, 2005 05:01 AM
Word to HTML Converter in VB.NET? Ron Howerton VB.NET 2002/2003 Basics 0 February 18th, 2004 03:51 PM



All times are GMT -4. The time now is 11:19 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.