Solved

Method Visible of object '_Worksheet' failed - Excel

Posted on 2013-11-05
7
2,276 Views
Last Modified: 2013-11-08
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
Comment
Question by:Conernesto
7 Comments
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
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
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
<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
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:Conernesto
Comment Utility
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
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
do you know the password to unprotect the workbook?
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
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
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now