0
我是一个新手,但是我使用下面的代码将整个文件夹中的.RTF
文件转换为.DOCX
文件。使用VBA将RTF转换为DOCX
Sub BatchConvertToDocx()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.rtf", vbNormal)
While strFile <> ""
Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
With wdDoc
.SaveAs2 FileName:=Left(.FullName, InStrRev(.FullName, ".")) & "docx", FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False
.Close wdDoNotSaveChanges
End With
strFile = Dir()
Wend
Set wdDoc = Nothing
App
lication.ScreenUpdating = True
End Sub
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
请问有人能告诉我如何隐藏输出.docx
文件中方括号之间的文本?
例如
Hi [This is the text that should be hidden] there.
而且,虽然转换.docx
文件返回到.rtf
文件,文本应该在输出.rtf
文件再次出现。
谢谢Peh,我在哪里添加到父代码?正如我所说我是一个新手:) – Allan
对不起,但StackOverflow不是一个免费的代码写作服务,也没有一个网站教你编码VBA(为此目的还有其他网站)。我只能显示可能性或技巧。如果你需要一个完整的工作代码,那么这是错误的地方。我上面的回答仅仅是一个展示案例,“如何实现”不是一个随时可用的解决方案。 –