Solved

Method Visible of object '_Worksheet' failed - Excel

Posted on 2013-11-05
7
2,525 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 39624537
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39624557
<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)
ID: 39624626
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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:Conernesto
ID: 39624976
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39625006
do you know the password to unprotect the workbook?
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39625012
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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39625036
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
office 2016 license quastion 3 43
Additional Controls in Excel VBA Does Not Show Anything 5 23
Reoccurring Access Query 24 46
Pull first name out of cell 2 28
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

732 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