怎么通过编程把一个WORD文件转换成Text文件?

jimshen 2005-12-28 08:26:43
怎么通过编程把一个WORD文件转换成Text文件?
...全文
286 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
darkseven 2006-01-04
  • 打赏
  • 举报
回复
Sub dsfg()
s文件名称=inputbox("文件名称呢:")

ActiveDocument.SaveAs FileName:= s文件名称 FileFormat:=wdFormatText, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, Encoding:=936, InsertLineBreaks:=False, AllowSubstitutions:=False, _
LineEnding:=wdCRLF
Application.WindowState = wdWindowStateNormal
Application.WindowState = wdWindowStateMinimize
Application.WindowState = wdWindowStateNormal
End Sub
OTT_FIRE 2005-12-30
  • 打赏
  • 举报
回复
其实你看看联机帮助就知道了,用saveas方法,下面是个例子。
本示例将活动文档保存为纯文本格式,文件的扩展名为“.txt”。

Sub SaveAsTextFile()
Dim strDocName As String
Dim intPos As Integer

'Find position of extension in filename
strDocName = ActiveDocument.Name
intPos = InStrRev(strDocName, ".")

If intPos = 0 Then

'If the document has not yet been saved
'Ask the user to provide a filename
strDocName = InputBox("Please enter the name " & _
"of your document.")
Else

'Strip off extension and add ".txt" extension
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".txt"
End If

'Save file with new extension
ActiveDocument.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatText
End Sub
northwolves 2005-12-28
  • 打赏
  • 举报
回复
save as

5,139

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 Office开发/ VBA
社区管理员
  • Office开发/ VBA社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧