代码如下:
Dim wdapp As Object
Dim wd As Object
Private Sub Command1_Click()
Set wdapp = CreateObject("Word.Application") '创建Word运用环境
Set wd = wdapp.Documents.open(App.Path & "\mi.docx") '打开Word
wdapp.Visible = True
End Sub
Private Sub Command2_Click()
wdapp.selection.insertafter "Hello World!" '插入相关字符!
MsgBox wdapp.selection.range.start
End Sub
Private Sub Form_Unload(Cancel As Integer)
wd.Close True '关闭Word文件
wdapp.Quit '退出word运用环境
End Sub
附件如下:
话说大哥,一分悬赏分都不给吗?专门给你写的代码和测试文件啊,你这个题怎么滴也得50分吧,我觉得!
试一下 SelStar SelLength SelText 属性