【问题标题】:change default save-as type in excel更改excel中的默认另存为类型
【发布时间】:2016-01-21 14:50:25
【问题描述】:

我有一个宏模板文件。它显示另存为对话框,默认为“.xls”格式。我想将默认类型显示为“.xlsm”。我需要使用 vba 来完成。

请任何人帮助我解决这个问题。

提前致谢!!!

【问题讨论】:

  • 我需要使用 vba - 请添加 vbaexcel-vba 标签并显示您尝试完成此操作的代码 以及失败的地方。
  • 感谢 Scott 的宝贵时间。下一次,我会发布我的代码。

标签: excel save


【解决方案1】:

请参考以下代码。它对我有用!

Dim FileSaveAsName As Variant, intchoice As Integer
Static saveProcess As Boolean 

If Not saveProcess Then 
    Application.EnableEvents = False
    Application.DisplayAlerts = False
    If SaveAsUI = True Then 'Save As... was selected
        saveProcess = True 
        Set FileSaveName = Application.FileDialog(msoFileDialogSaveAs)

        FileSaveName.InitialFileName = ThisWorkbook.Name
        FileSaveName.FilterIndex = 2   'select to save with a ".xlsm" extension
        intchoice = FileSaveName.Show
        If intchoice <> 0 Then
            FileSaveName.Execute
        End If
        Cancel = True
    Else 'Normal Save 
        saveProcess = True 
        Cancel = True
        ThisWorkbook.Save 
    End If
    saveProcess = False 
    Application.EnableEvents = True
    Application.DisplayAlerts = True
End If

【讨论】:

  • 虽然此代码可能会回答问题,但提供有关它如何和/或为什么解决问题的额外上下文将提高​​答案的长期价值。
猜你喜欢
  • 1970-01-01
  • 2021-11-23
  • 2014-09-27
  • 1970-01-01
  • 2023-03-10
  • 1970-01-01
  • 1970-01-01
  • 2023-03-31
  • 2020-10-02
相关资源
最近更新 更多