VBA 另存为另存为文件类型而不是 .xlsm [英] VBA SaveAs saving as File type instead of .xlsm

查看:251
本文介绍了VBA 另存为另存为文件类型而不是 .xlsm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户打开此工作簿时,我想强制他们立即将文件另存为新文件.对话框打开,但它只会让您将其另存为所有文件".

When a user opens up this workbook, I want to force them to save the file as a new file immediately. The dialog box opens up but it will only let you save it as "All Files".

Dim Workbook_Orig As Variant

    Workbook_Orig = Application.GetSaveAsFilename

    If Workbook_Orig <> False Then
        ActiveWorkbook.SaveAs _
        Filename:="File Name", _
        FileFormat:=52
    End If

代替52",我尝试了xlOpenXMLWorkbookMacroEnabled",但没有任何区别.

In place of the "52" I've tried "xlOpenXMLWorkbookMacroEnabled" but that made no difference.

不能立即另存为吗?您是否必须更改文件或其他内容?

Can you not SaveAs immediately? Do you have to make a change to the file or something?

非常感谢任何帮助.

推荐答案

更改 FileFormat 仅当他们未在对话框中选择任何内容时才有意义(因为这是唯一一次 workbook_orig = False)

Changing the FileFormat only matters if they don't select anything in the dialogue box (since that is the only time workbook_orig = False)

尝试指定文件过滤器参数

Workbook_Orig = Application.GetSaveAsFilename(fileFilter:="Excel Macro-Enabled Workbook (*.xlsm),*.xlsm")

在您的 GetSaveAsFileName 指令中.

这篇关于VBA 另存为另存为文件类型而不是 .xlsm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆