将复选框列表项导出到msword [英] Export checklistbox items to msword

查看:105
本文介绍了将复选框列表项导出到msword的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的清单框项目从vb.net格式导出到VB.net中的ms字

I want to export my checklistbox items from vb.net form to ms word in VB.net

推荐答案

这里有一个轴心;)
在表单(Button1)上插入按钮,然后复制并粘贴以下代码.

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

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


这篇关于将复选框列表项导出到msword的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆