vba Internet Explorer 中的 Excel 宏......无法运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2230756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Excel Macro in Internet Explorer....can't run
提问by user269647
I have created an Excel 2003 (.xls) file (created macro using VBA). The Excel file is protected and has hidden worksheets. When I try to run the Excel macro in Internet Explorer, I get an error message "Method of class "Sheets" failed in object _Global". The macro runs fine in Excel.
我创建了一个 Excel 2003 (.xls) 文件(使用 VBA 创建的宏)。Excel 文件受到保护并具有隐藏的工作表。当我尝试在 Internet Explorer 中运行 Excel 宏时,收到错误消息“对象 _Global 中的类“Sheets”的方法失败”。宏在 Excel 中运行良好。
I'm guessing that IE doesn't access the worksheets (hidden or otherwise) in the Excel Workbook.
我猜 IE 不会访问 Excel 工作簿中的工作表(隐藏或其他方式)。
Is there a way to declare the "sheets" or "worksheets" variable in my Excel VBAcode so that the Excel macros can run in the IE window as well?
Is there a workaround to fix this problem?
I have to run the macro in IE.
有没有办法在我的Excel VBA代码中声明“工作表”或“工作表”变量,以便 Excel 宏也可以在 IE 窗口中运行?
是否有解决此问题的解决方法?
我必须在 IE 中运行宏。
回答by MikeD
You can offer your Excelfile for download. This way each user can run it on his/her own machine. Just provide a link to its location on a Web page, then the user can decide to download or run immediately. Naturally any modifications the user does, would not flow back into the source.
您可以提供 Excel 文件以供下载。这样每个用户都可以在他/她自己的机器上运行它。只需提供一个指向其在网页上的位置的链接,用户就可以决定是下载还是立即运行。自然地,用户所做的任何修改都不会流回到源中。
回答by user269647
I found out what the issue was in my case. When the Excel file is opened in Internet Explorer, the sheets that are being accessed will have to be un-hidden and selected
我发现了我的情况是什么问题。在 Internet Explorer 中打开 Excel 文件时,必须取消隐藏和选择正在访问的工作表
In my case: Application.ThisWorkbook.Sheets("Hose_Blk_mtrl").Visible = True Application.ThisWorkbook.Sheets("Hose_Blk_mtrl").Select
在我的例子中: Application.ThisWorkbook.Sheets("Hose_Blk_mtrl").Visible = True Application.ThisWorkbook.Sheets("Hose_Blk_mtrl").Select
Also, the Workbook should be "UnProtected" so that the above two lines in code will not generate any error. The Worksheets can be hidden again after the execution of the code by
此外,工作簿应该是“UnProtected”,这样代码中的上述两行就不会产生任何错误。工作表可以在代码执行后再次隐藏
Application.ThisWorkbook.Sheets("Hose_Blk_mtrl").Visible = False
Application.ThisWorkbook.Sheets("Hose_Blk_mtrl").Visible = False
So, Internet Explore CAN host excel files with in-built Macros.
因此,Internet Explore 可以使用内置宏来托管 excel 文件。
-Rishi
-理士
回答by Apocatastasis
I don't understand what you're doing. The Excel macros runs only on Excel. May be you download a Excel file, and the macros doesn't run? If you need a macro for IE, [check this][1]
我不明白你在做什么。Excel 宏仅在 Excel 上运行。可能你下载了一个 Excel 文件,但宏没有运行?如果你需要一个 IE 的宏,[检查这个][1]
[1]: http://download.cnet.com/iMacros-for-Internet-Explorer/3000-12512_4-10586882.html/"check this"
[1]:http: //download.cnet.com/iMacros-for-Internet-Explorer/3000-12512_4-10586882.html/“检查这个”