声明关闭时编译错误 [英] Compile error while declaring close

查看:161
本文介绍了声明关闭时编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

平台:Microsoft Visual Basic 6.5和MS Excel 2007

Platform : Microsoft Visual Basic 6.5 and MS Excel 2007

我正在尝试一个宏来对excel启用文件进行一些编辑。完成关于如何关闭Excel文件而不保存的研究。 网页在我可以使用该方法之前教导我进行声明。我插入复制命令并尝试编译。收到编译错误,预期结束语句。任何人知道声明有什么问题?

I am trying to do a macro to do some editing to an excel enable file. Done research on how to close the Excel file without saving. The webpage teaches me to put declaration before I can use the method. I insert copy the command in and try to compile. Got compilation error, expected end of statement. Anyone know what's wrong with the declaration?

Public Overridable Sub Close ( _
    <OptionalAttribute> SaveChanges As Object, _
    <OptionalAttribute> Filename As Object, _
    <OptionalAttribute> RouteWorkbook As Object _
)

Private Sub WorkbookClose()
    Me.Close(False, False)
End Sub


推荐答案

如果它的宏在excel中将以下代码复制到本工作簿的代码段。

If its macro in excel copy the below code to thisworkbook section of code.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Me.Close False
End Sub

这篇关于声明关闭时编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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