• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3082
  • Last Modified:

Method Visible of object '_Worksheet' failed - Excel

I am running some code to open an Excel template and save it with a different name. I get the obove message when I run the code. I don't know what is cousing this. From Access, the Excel template is opened and I get the Title message.
1 Solution
Hard to say without actually seeing your code.

Does your code hide/show worksheets at any point?  You'll get this error if you don't leave at least one worksheet visible.
Rey Obrero (Capricorn1)Commented:
<I am running some code to open an Excel template>

is this really a template (extension .xlt) ?  or just a normal Excel file .xls, .xlsx extension
Dale FyeCommented:
agree with miriam.

Are you really trying to hide/unhide worksheets, or are you trying to make Excel visible, so that you can see the template workbook?

I usually do something like:

Dim xl as Object  'Excel.Application if you want intellisense
Dim wbk as Object
Dim sht as Object

set xl = GetObject("Excel.Application") 'assumes Excel is already open
xl.Visible = true

set wbk = xl.Activeworkbook
wbk.sheets(1).Visible = False 'or True
wbk.sheets("SheetName").visible = False  'or True

'do something else here

wbk.SaveAs Filename
set wbk = nothing
set xl = nothing
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

ConernestoAuthor Commented:
I think that my problem has to do with protection. I have various sheets within my workbook. My worksheet is saved as an older version of Excel *.xls.  When I open my worksheet and go to File Info Under Permissions it states "The structure of the worksheet has been locked to prevent unwanted changes, such as moving, deleting, or adding sheets.

I need the Permissions to say "Anyone can open, copy, and change any part of this workbook."

How do I change permissions to Anyone can open....?
Rey Obrero (Capricorn1)Commented:
do you know the password to unprotect the workbook?
This shows how to unlock an Excel 2003 spreadsheet:


You might need a password (we can't help with breaking password protection, of course)

Also take a look at this, about unlocking specific portions:

The interface may differ depending on your Excel version,
Rey Obrero (Capricorn1)Commented:
here's how to unlock the excel in vba

Sub UnlockXL()
Dim xlObj As Object, xlPath As String
Dim wkbpwd As String, shtpwd As String
wkbpwd = "<pwd for workbook>"
shtpwd = "<pwd for sheet>"
xlPath = CurrentProject.Path & "\ExcelFile.xls"
Set xlObj = CreateObject("excel.application")
    xlObj.workbooks.Open xlPath
    With xlObj
        .Worksheets("NameOfsheet").unprotect shtpwd
        .activeworkbook.unprotect wkbpwd
    End With
    Set xlObj = Nothing

End Sub
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now