在word中保存为文件名 [英] getting save as file name in word
本文介绍了在word中保存为文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的代码中,文件名是硬编码的,但我希望用户能够选择它.
In the code below the file name is hard coded, but I want the user to be able to pick it.
我正在阅读有关 GetSaveAsFilename
的信息,但在使用它时出现错误:找不到方法或成员".
I was reading about GetSaveAsFilename
but I get an error when using it: "method or member not found".
fileSaveName = Application.GetSaveAsFilename _
(fileFilter:="Excel Files (*.txt), *.txt")
这是为 Word 2010 编写的.我认为 GetSaveAsFilename
在 Word VBA 中是否可用?
This is written for Word 2010. Am I wrong in thinking GetSaveAsFilename
is available in word VBA?
Sub Macro3()
'
' Macro3 Macro
'
'
ActiveDocument.SaveAs2 FileName:="Questionnaire01-05-20122.txt", _
FileFormat:=wdFormatText, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=True, SaveAsAOCELetter:=False, Encoding:=1252, InsertLineBreaks:=False, _
AllowSubstitutions:=False, LineEnding:=wdCRLF, CompatibilityMode:=0
End Sub
推荐答案
你可以像这样给对话框提供一个包含文件名的默认路径,即
You can provide a default path including filename like so to the dialog, ie
Sub SaveName()
Dim strFileName As String
Dim StrPath As String
'provide default filename
StrPath = "c: emp est.docx"
With Dialogs(wdDialogFileSaveAs)
.Name = StrPath
If .Display <> 0 Then
strFileName = .Name
Else
strFileName = "User Cancelled"
End If
End With
MsgBox strFileName
End Sub
这篇关于在word中保存为文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文