|
楼主 |
发表于 2018-3-1 21:41
|
显示全部楼层
我又调试了,原因好像找到了,但不知道如何解决?
下面代码放在VB6中,运行。
Private Sub Command1_Click()
Dim i As String, j As String, m As String, n As String
Dim Myword As Word.Application
Dim MyDocument As Word.Document
Dim MyRange As Word.Range
On Error Resume Next
Set Myword = CreateObject("Word.Application")
Myword.Visible = True
Set MyDocument = Myword.Documents.Open("C:\Documents and Settings\Administrator\桌面\123.docx")
Myword.ActiveWindow.Activate
Myword.Selection.HomeKey Unit:=wdLine
Myword.Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend
Myword.Selection.Copy
i = Clipboard.GetText()
i = Replace(Replace(Replace(i, vbCr, ""), vbLf, ""), " ", "")
Clipboard.Clear
MyDocument.SaveAs "C:\Documents and Settings\Administrator\桌面\" & i & ".doc"
MyDocument.Close
Clipboard.Clear
Myword.Quit
Set MyDocument = Nothing
Set Myword = Nothing
End Sub
上述代码中:Count:=3时,另存为不成功;Count:=1时,另存为成功不知道什么原因?
|
|