• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2911
  • 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.
0
Conernesto
Asked:
Conernesto
1 Solution
 
mbizupCommented:
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.
0
 
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
0
 
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
wbk.close
set wbk = nothing
xl.Quit
set xl = nothing
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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....?
0
 
Rey Obrero (Capricorn1)Commented:
do you know the password to unprotect the workbook?
0
 
mbizupCommented:
This shows how to unlock an Excel 2003 spreadsheet:

http://www.ehow.com/how_6395137_unlock-excel-2003-spreadsheet.html

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:
http://office.microsoft.com/en-us/excel-help/lock-or-unlock-specific-areas-of-a-protected-worksheet-HA010096837.aspx

The interface may differ depending on your Excel version,
0
 
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").Activate
        .Worksheets("NameOfsheet").unprotect shtpwd
        .range("A2").select
        .activeworkbook.unprotect wkbpwd
        .activeworkbook.Save
    End With
    xlObj.Quit
    Set xlObj = Nothing

End Sub
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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