CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_studio_2005 Tags:
Item Type: Date Entered: 2/5/2008 3:33:56 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 6 Views: 409 Favorited: 0 Favorite
7 Items, 1 Pages 1 |< << Go >> >|
ratkinso
Asp.Net User
Protect excel worksheets2/5/2008 3:33:56 PM

0

Hi all, I am trying to take an excel file and protect the worksheets.  Does anyone know of a good video to watch for this or a good starting point.  I am trying to use the following but getting an active x error on the oExWb = CreateObject("Excel.Workbook").  Not even sure if I am on the right road with this though.

Thanks,

Randy

Dim oExApp As Object
oExApp = CreateObject("Excel.Application")
Dim oExWb As Object
oExWb = CreateObject("Excel.Workbook")
Dim oExWs As Object
oExWs = CreateObject("Excel.Worksheet()")
oExWb = oExApp.Workbooks.Open(path & BranchName)
Dim iWsCount As Integer
iWsCount = oExWb.Worksheets.Count
oExWs = oExWb.Worksheets(1)
For Each oExWs In oExWb.Worksheets
oExWs.Protect(
"Safety732")
Next
oExWb.Save()
oExWb.Close()
oExWs =
Nothing
oExWb = Nothing
oExApp = Nothing


 


Click on 'Mark as Answer' if this post is helpful.

-- Randy
ratkinso
Asp.Net User
Re: Protect excel worksheets2/5/2008 8:47:01 PM

0

ok, got it all to work on my local, but does not work on server...???  Works perfectly on my machine, on server it dies out somewhere that it starts in with the Excel.  I can tell this because it does the copying of files and everything up to that point.  Any ideas from anyone??  Here is code that worked.

Dim oExApp As New Excel.Application
Dim oExWb As Excel.Workbook
Dim oExWs As Excel.Worksheet

oExWb = oExApp.Workbooks.Open(path & BranchName)

Dim iWsCount As Integer
iWsCount = oExWb.Worksheets.Count
For Each oExWs In oExWb.Worksheets
oExWs.Protect(
"Safety732")
Next

oExWb.Save()
oExWb.Close()


Click on 'Mark as Answer' if this post is helpful.

-- Randy
ratkinso
Asp.Net User
Re: Protect excel worksheets2/5/2008 9:33:46 PM

0

The server has Office XP installed and I am using Office 2003 and Office 2007.  Do I need to update the Office version??  I copied the DLL files to it that were added to my Bin directory when I added the Office 11 Excel Library....  But it is still needing something...   Do I have to have Office 2003 to use with Interop


Click on 'Mark as Answer' if this post is helpful.

-- Randy
ratkinso
Asp.Net User
Re: Protect excel worksheets2/6/2008 1:58:55 PM

0

Well, since the server had Office XP, I installed XP on my system and added the reference to "Microsoft Excel 10.0 Object Library" and am still having the same problem.  I hate for this to be such a show stopper, since it is working....  Just not on the server, which of course is the whole point....  I deleted the reference to 11 in my web.config, but noticed that there was no reference to "Microsoft Excel 10.0 Object Library" in there???  But there was a DLL in the Bin, so I gather that is what it is using??  Or does there need to be a reference in the web.config for it??  It still works just fine on my local system, so not sure that is even an isuue.

Thanks
Randy


Click on 'Mark as Answer' if this post is helpful.

-- Randy
ratkinso
Asp.Net User
Re: Protect excel worksheets2/6/2008 4:53:50 PM

0

A little bit of new information, I have the error now...  Hopefully this will help someone...

System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for
component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005.
at _CopyBranchDriversMatrixUpload5826klo.Button1_Click(Object sender, EventArgs e) in
E:\Inetpub\wwwroot\website\Copy of BranchDriversMatrixUpload5826klo.aspx.vb:line 58

 

This is line 58:

Dim oExApp As New Excel.Application

Thanks
Randy


Click on 'Mark as Answer' if this post is helpful.

-- Randy
ratkinso
Asp.Net User
Re: Protect excel worksheets2/6/2008 5:37:40 PM

0

Am I asking this in a confusing manner or does just no one else have any idea on this either??  Just want to make sure the problem is understood.  I have seen other people on the web having similar problems, but no answers...  Here is the revised code, but I don't think the code is the problem, since it runs fine on my local system and just not on the server, error is in above post:

' =================== Protect Worksheets
Dim oExApp As New Excel.Application
Dim oExWb As Excel.Workbook
Dim oExWs As Excel.Worksheet
oExWb = oExApp.Workbooks.Open(path & BranchName)
Dim iWsCount As Integer

iWsCount = oExWb.Worksheets.Count
For Each oExWs In oExWb.Worksheets
oExWs.Protect(
"Safety732")
Next
oExWb.Save()
oExWb.Close()
oExWs =
Nothing
oExWb = Nothing
oExApp = Nothing
command.Connection.Close()
Label1.Text =
"File uploaded!"
Catch ex As Exception
Label1.Text = ex.ToString


Click on 'Mark as Answer' if this post is helpful.

-- Randy
ratkinso
Asp.Net User
Re: Protect excel worksheets2/6/2008 9:38:12 PM

0

I have fixed the problem.  I had to add ALL USERS to the Excel Application and that got it working.


Click on 'Mark as Answer' if this post is helpful.

-- Randy
7 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Excel hacks Authors: Raina Hawley, Pages: 283, Published: 2004
Special edition using Microsoft Office 2003 Authors: Ed Bott, Woody Leonhard, Pages: 1324, Published: 2003
Excel Hacks: Tips & Tools for Streamlining Your Spreadsheets Authors: Raina Hawley, Pages: 386, Published: 2007
Visual studio tools for Office: using Visual Basic 2005 with Excel, Word, Outlook, and InfoPath Authors: Eric Carter, Eric Lippert, Pages: 992, Published: 2006
Excel 2007 Workbook for Dummies Authors: Greg Harvey, Pages: 408, Published: 2007

Web:
Spreadsheet Page Excel Tips: Spreadsheet Protection FAQ How is worksheet protection different in Excel 2002 and later? ... When you protect a worksheet using Excel 2002 or later, you are given a number of options ...
Excel: Password Protect/Unprotect All Excel Worksheets in One Go. Excel VBA Macro Code That Will Password Protect and Unprotect all Worksheets in any Excel Workbook.
How to: Protect Worksheets The protection feature in Microsoft Office Excel 2003 keeps users or code from modifying objects within a worksheet. Once you enable protection for a ...
Excel Worksheet Protection - WorldStart Computer Tips and Computer ... Excel Worksheet Protection. So, we're all looking to protect our worksheets from changes—changes others may make or changes we may accidentally make. ...
Less is more: ”How do I protect an Excel worksheet and still allow ... Jan 23, 2007 ... If you protect a worksheet in Excel (by selecting Tools -> Protection -> Protect Worksheet), by default all the cells will be locked, ...

Protect excel worksheets - ng.asp-net-forum.visual_studio_2005 Protect excel worksheets, > ROOT > NEWSGROUP > Asp.Net Forum > visual_studio. visual_studio_2005, Date: 2/5/2008 3:33:56 PM, Replies: 6, ...

Videos:
Microsoft Excel Worksheet Protection Microsoft Excel worksheet protection demo
Protect formulas and cells in an Excel worksheet Hiding the formulas from the users and allowing only specific cells to be edited in an Excel worksheet has many advantages.
Excel 229 – Learn Excel from MrExcel – Protect Formulas How to protect only the formula cells in your worksheet. Epiosde 229 shows you how. This blog is the video podcast companion to the book, Learn ...
Protect an Excel Worksheet http://www.business-excel-training-course.com/ This video will show you step by step how you can protect a range of cells in an Excel worksheet so ...
Learn Excel from MrExcel Episode 763 - Protecting Cells When you use Tools, Protect Worksheet, all of the cells become protected. How can you protect only a portion of the worksheet? In Episode 763, we ...












email alert service

reference an assembly from gac

properties window problems

run reflector inside vs2005 ide

vs2005 add-in suggestion

what program runs when i start debugging?

selective build question

how to remerber password on ftp log on vs.net 2005

project adding new item doesn't give me the .ascx option of a file ?

problem running net 2.0 websites in http/local iis mode

changing the default language of the dataset designer class code

studio forgets my toolbar positioning

what not to do when installing vs 2005 sp1?

how do i enable toolbox tabs that are disabled

debugging website in a solution with many websites starts many web server instances

problems with built in web server

find in files, file types/filter

code formatting when refactoring

problem (unable to add data connection, the dataconnectiondialog could not be intialized)

messages to debug window from custom build provider

problem with web application projects and code-behind

debugging a remote process

properties window populates nothing

vs 2k5 asp.net 2.0 beta 2 migration problem

using visual studio 2005 with installshield 12 to get the installer for a web application

vs hangs when adding a web project

controls, <register namespace="dll.mycontrol" assembly = "swapyourvacationhome"> in vs2005

which version of service pack 2 do i need to install visual studio 2005?

visual studio forcing me to enter optional parameters

website publish - exclude images?

simple form gets system.io.filenotfoundexception when run on non-development system

create user wizard : password policy

button click cs file issues....

macros

hide output pane

migration assistant not showing up in my available converters in vs 2005

strange visual studio problem

should i buy visual studio 2005 or get visual web developer express

moving absolutely positioned controls scrambles code in aspx page

suggestion for the listitem collection editor

visual basic 20005 - connect access database

can't open project w/o opening entire solution

vs 2005, viewing all files option

class is ambiguous in app_web_twuugmrf.2 ?

adding a projects reference in vs.net 2005

some question about connecting sql server

problems with properties window in visual studio 2005

debugging in vista

recent projects list

adding a control to the toolbox

 
Search This Site:

 
  Privacy | Contact Us
All Times Are GMT