如果取消保存副本,如何停止宏

发布于 2024-08-16 12:03:18 字数 490 浏览 0 评论 0原文

问候一并 - 对于仍在查看此网站的任何人来说,这都是一个圣诞难题......这可行,但如果我决定取消该过程(即在此阶段不保存文件并停止该过程),它不会保存该文件,但以下 marco (filltolastrow2) 仍然处于激活状态,如何阻止这种情况发生?

Public Sub SaveaCopyIncomeSheet()
    Dim file_name As Variant
    file_name = Application.GetSaveAsFilename("Overdue Report - Draft", filefilter:="Excel Files(*.xls),*.xls")
    If file_name <> False Then
       ActiveWorkbook.SaveAs Filename:=file_name
        MsgBox "File Saved!"
    End If
    filltolastrow2
End Sub 

Greetings one and all - a christmas puzzle for anyone still looking at this site...This works but if i decide to cancel the process (ie not save a file and stop the process at this stage) it doesn't svae the file but the following marco (filltolastrow2) is still activated how can I stop this happening?

Public Sub SaveaCopyIncomeSheet()
    Dim file_name As Variant
    file_name = Application.GetSaveAsFilename("Overdue Report - Draft", filefilter:="Excel Files(*.xls),*.xls")
    If file_name <> False Then
       ActiveWorkbook.SaveAs Filename:=file_name
        MsgBox "File Saved!"
    End If
    filltolastrow2
End Sub 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木緿 2024-08-23 12:03:18

你可能想要

If file_name <> False Then
   ActiveWorkbook.SaveAs Filename:=file_name
   MsgBox "File Saved!"
   filltolastrow2
End If

You possibly want

If file_name <> False Then
   ActiveWorkbook.SaveAs Filename:=file_name
   MsgBox "File Saved!"
   filltolastrow2
End If
無處可尋 2024-08-23 12:03:18

选择:

Public Sub SaveaCopyIncomeSheet()
    Dim file_name As Variant
    file_name = Application.GetSaveAsFilename("Overdue Report - Draft", filefilter:="Excel Files(*.xls),*.xls")

    If file_name = False Then GoTo E_NoFileName

    ActiveWorkbook.SaveAs Filename:=file_name
    MsgBox "File Saved!"
    filltolastrow2

Exit Sub
E_NoFileName:
    MsgBox "File Not Saved"
End Sub

Alternative:

Public Sub SaveaCopyIncomeSheet()
    Dim file_name As Variant
    file_name = Application.GetSaveAsFilename("Overdue Report - Draft", filefilter:="Excel Files(*.xls),*.xls")

    If file_name = False Then GoTo E_NoFileName

    ActiveWorkbook.SaveAs Filename:=file_name
    MsgBox "File Saved!"
    filltolastrow2

Exit Sub
E_NoFileName:
    MsgBox "File Not Saved"
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文