0
votes

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.

I'm guessing that IE doesn't access the worksheets (hidden or otherwise) in the Excel Workbook.

Is there a way to declare the "sheets" or "worksheets" variable in my Excel VBA code 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.

3
I think the issue is with your code, can you post it?Irwin M. Fletcher
Irwin, I can e-mail it to you. The code that I have written, even though basic has a lot of lines of code. I've created a userform with about 25-30 textboxes and 4 listboxes. The textboxes are populated based on selection of the listbox items. The remaining textboxes are filled by using excel funtion "vlookup". Example: v = Application.WorksheetFunction.VLookup(-6, Sheets("Hose_Blk_mtrl").Range("H5:L12"), 5, False) is used to fill in the Textboxes. The "Hose_Blk_mtrl" sheet is hidden in the workbook. I don't know if I've missed declaring something. Again, the macro runs fine in excel.user269647
I think email code is discouraged around here. It makes since that your code would work when run from excel, if you are creating an new object that IE can not handle then it would throw an error. If you can just post of few examples of the code, it may give me a better view of what the issue may be. Just pick some different areas and post them first.Irwin M. Fletcher
Irwin, I'm posting a few lines from each of my module like you asked. For the Userform: Private Sub UserForm_Initialize() ListBox1.AddItem ("XT3") ListBox1.AddItem ("XT5ToughGuard") CommandButton1.Enabled = False End Subuser269647
"a" is the user selected item in the listbox. If a = "XT5" Then Select Case t Case "-12" v = Application.WorksheetFunction.VLookup(-12, Sheets("Hose_Blk_mtrl").Range("O8:P12"), 2, False) Case "-16" v = Application.WorksheetFunction.VLookup(-16, Sheets("Hose_Blk_mtrl").Range("O8:P12"), 2, False) Case Else 'result_else End Select Call textbox_clear End Ifuser269647

3 Answers

1
votes

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.

1
votes

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

In my case: 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

Application.ThisWorkbook.Sheets("Hose_Blk_mtrl").Visible = False

So, Internet Explore CAN host excel files with in-built Macros.

-Rishi

0
votes

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]

[1]: http://download.cnet.com/iMacros-for-Internet-Explorer/3000-12512_4-10586882.html/"check this"