Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to export my checklistbox items from vb.net form to ms word in VB.net
Posted
Comments
ChandraRam 8-Oct-11 15:29pm    
Search for "Word automation" - you should find loads of samples.
Maciej Los 13-Oct-11 17:26pm    
I think, no one can understand what you mean, what you are trying to do.

1 solution

Here you have an axample ;)
Insert button on the form (Button1) and copy and paste the code below.

VB
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim i As Integer = 0, cb As Object = Nothing
    Dim wrdApp As Object = Nothing, wrdDoc As Object = Nothing, wrdRng As Object = Nothing

    Try
        'create Word App instance
        wrdApp = CreateObject("Word.Application")
        'add new document
        wrdDoc = wrdApp.Documents.Add()
        wrdRng = wrdDoc.Range
        'enum items od CheckedListBox
        For i = 0 To Me.CheckedListBox1.Items.Count - 1
            cb = Me.CheckedListBox1.Items(i)
            wrdRng.InsertAfter("Item index: " & i.ToString & " - checked: " & Me.CheckedListBox1.GetItemChecked(i))
            wrdRng.InsertParagraphAfter()
        Next
        wrdApp.Visible = True

    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error...")
    Finally
        cb = Nothing
        wrdRng = Nothing
        wrdDoc = Nothing
        wrdApp = Nothing

    End Try
End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900