- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下代码保存 Excel 工作表的选定区域。但是,如果我尝试保存与已存在的文件具有相同文件名的文件,它只会保存该文件,而不会显示“是否要覆盖该文件”对话框。
有没有办法更改此代码,以便它会询问我是否要覆盖预先存在的文件?
Option Explicit
Sub CreatePDF()
Dim wSheet As Worksheet
Dim vFile As Variant
Dim sFile As String
Set wSheet = ActiveSheet
sFile = Replace(Replace(wSheet.Name, " ", ""), ".", "_") _
& "_" _
& Format(Now(), "yyyymmdd\_hhmm") _
& ".pdf"
sFile = ThisWorkbook.Path & "\" & sFile
vFile = Application.GetSaveAsFilename _
(InitialFileName:=sFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
If vFile <> "False" Then
wSheet.Range("B2:J44").ExportAsFixedFormat _
Type:=xlTypePDF, _
FileName:=vFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
MsgBox "PDF file has been created."
End If
End Sub
最佳答案
按照建议,模拟行为的一种方法是检查所选的 SaveAsFilename:
Option Explicit
Sub CreatePDF()
Dim wSheet As Worksheet
Dim vFile As Variant
Dim sFile As String
Set wSheet = ActiveSheet
sFile = Replace(Replace(wSheet.Name, " ", ""), ".", "_") _
& "_" _
& Format(Now(), "yyyymmdd\_hhmm") _
& ".pdf"
sFile = ThisWorkbook.Path & "\" & sFile
vFile = Application.GetSaveAsFilename _
(InitialFileName:=sFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
If Dir(vFile) > vbNullString Then _
If MsgBox("Overwrite File?", _
vbExclamation + vbYesNo, "Overwrite?") = vbNo Then Exit Sub
If vFile <> "False" Then
wSheet.Range("B2:J44").ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=vFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
MsgBox "PDF file has been created."
End If
End Sub
关于vba - 使用 VBA 保存时显示 "Do you want to overwrite the file"对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31114763/
正如主题所说.. 我如何告诉 GCC 允许我使用 SSE4.1 内在函数但不使用 SSE4.1 进行优化(例如,通过将 SSE4.1 字符串比较)贯穿所有其余代码翻译单元? 最佳答案 您可以使用 Fu
为了简单起见,假设我有表 users 和 interests 用户 id | name --------- 1 | amy 2 | brian 3 | carole 兴趣 uid | inter
我进行了一系列测试来开发一个简单的游戏,并且我已经达到了 Mockito 的 InOrder.verify() 产生错误的程度。 Verification in order failure. Want
哪种方法更好以及为什么。 最佳答案 不要使用是/否问题,而是使用带有自定义按钮的问题: The file blah.txt has been modified. Would you like to s
您好,我想使用以下命令放置多行描述 p4 --field Description="MY CLN Header \\n my CLN complete description in two -thre
我正在使用 jQuery Fancybox 弹出注册表单 here 我希望表单的大小为 450px x 700px,但无论我设置什么高度和宽度,我都会得到滚动条: $(document).r
大家好我在徘徊是否有一种简单的方法可以在没有 android 布局的情况下执行以下操作将图像放在中央顶部放置一个按钮中心中心在左下角放置一个按钮在右下角放置一个按钮 听起来没那么难吧? 好吧,我想不出
我正在尝试为我的 SOAP 请求添加安全性。我想在两个级别允许它:1. 基本 ssl。 2. 带证书的SSL。 我尝试在tomcat中设置Server.xml来使用clientAuth="want",
我有一个在页面中间有一个表格 View 的布局。我希望根据用户设备的屏幕尺寸任意调整表格 View 的大小。在 ascii 中: +-----------+ |some stuff | +------
我面临以下问题,我试图呈现一个 modalViewController 并使其覆盖整个屏幕,例如: [controller setWantsFullScreenLayout:yes]; [myNavC
我正在使用 MMDraweController。它完美地工作。我对 rootViewController 有疑问。当应用程序启动时,它会加载 loginViewController。所以我不想要侧边栏
我搜索了互联网和 SO,但无法找到解决此问题的方法。我正在使用混帐。我有代码,它在计算机 C1 上有一个分支 B1。在另一台计算机 C2 上,我克隆了这个分支并在本地创建了另一个分支 B2。 B2 未
我正在使用以下 CSS 将我的彩色图像转换为灰度图像。 img.desaturate{ filter: grayscale(100%); -webkit-filter: graysca
从 Windows 11 升级后,Select-String cmdlet 停止工作,每次我使用它时,它都会尝试“打开未知文件”,如下图所示: 我在尝试从批处理文件运行我的一个 ps 脚本时发现了它
只是想知道我的浏览器一直询问我是否想在每次点击浏览器链接刷新时停止调试非常烦人,因为这会减慢开发时间。 有没有其他人遇到过这个? 干杯 最佳答案 更新的答案,现在找到根本原因 经过两年看到这个错误时断
在使用 Linux 时,当我们尝试使用命令行安装某些东西时,我们会收到一个提示 "Do you want to continue"[Y/N].. 我想使用 ansible-playbook 自动化它。
我们使用 cruise control .net在我们的 Delphi 2006 应用程序中进行持续集成。我们使用类似于描述的设置 here . 问题: 1) 用于实现构建脚本的最佳脚本工具/语言是什
昨天,Photo 的应用程序在我的 iPhone 上崩溃了。我想知道发生了什么以及导致崩溃的原因。我打开应用程序,它立即崩溃(黑屏然后回到跳板)。 在我打开应用程序之前,iPhone 没有“激活”(
我正在尝试编写一个小守护程序,检查是否有邮件要发送,如果需要则执行工作,然后休眠 X 秒。 我对NodeJS的异步方式不太熟悉。所以我迷路了。 var sleep = require('sleep')
我的文本框中有一个字符串,并且只希望其中一个单词以粗体显示。有没有办法在代码中做到这一点而不附加文本?有点像在 xml/html 中如何完成...下划线也可以吗? 最好不要使用 xml 或 html
我是一名优秀的程序员,十分优秀!