首页 > 编程 > .NET > 正文

1.word打开与关闭(VB.NET)

2024-07-10 13:00:37
字体:
来源:转载
供稿:网友
 

imports word

     '打开

     dim  mwordapp as word.application            'word 应用程序

     dim  mobjdoc as word.document                  'word 文档

     dim fullfilename as string                                '文件路径

     mwordapp = createobject("word.application")

     mobjdoc = mwordapp.documents.add(fullfilename)

             '关闭

           dim missing as object = system.reflection.missing.value

            mwordapp.application.quit()

            if not mobjdoc is nothing then

                '垃圾回收

                system.runtime.interopservices.marshal.releasecomobject(mobjdoc)

                mobjdoc = nothing

            end if

            if not mwordapp is nothing then

                system.runtime.interopservices.marshal.releasecomobject(mwordapp)

                mwordapp = nothing

            end if

            '真正释放word进程

            gc.collect()

商业源码热门下载www.html.org.cn

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表