引用:
Microsoft Word 11.0 Object Library
Microsoft Office 11.0 Object Library
代码如下:
Imports
Microsoft.Office.Interop
Public ClassForm1 ClassForm1
PrivateSubButton1_Click()SubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click
Dimm_objAsObject=System.Reflection.Missing.Value
DimappAsNewWord.Application
DimdocAsWord._Document
Try
doc=CType(app.Documents.Add(m_obj),Word._Document)
app.Selection.TypeText("我是塞北的雪http://blog.csdn.net/precipitant")
doc.SaveAs("c:NorthSnow.doc")
doc.Close()
app=Nothing
MsgBox("创建word完毕")
CatchexAsException
MsgBox(ex.Message)
EndTry
EndSub
EndClass
Public ClassForm1 ClassForm1
PrivateSubButton1_Click()SubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click
Dimm_objAsObject=System.Reflection.Missing.Value
DimappAsNewWord.Application
DimdocAsWord._Document
Try
doc=CType(app.Documents.Add(m_obj),Word._Document)
app.Selection.TypeText("我是塞北的雪http://blog.csdn.net/precipitant")
doc.SaveAs("c:NorthSnow.doc")
doc.Close()
app=Nothing
MsgBox("创建word完毕")
CatchexAsException
MsgBox(ex.Message)
EndTry
EndSub
EndClass