473,396 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

xlNoSelection not persisting after the file is closed

Hello all,

I am creating a report generation program with VB 6.0 as front-end and Oracle 10i as back-end. My reqiurements are
1. User will query the database through the front-end.
2. The results will get populated in an MSHFlexGrid.
3. There will be a button at the bottom captioning "Export to excel" clicking which shoud generate an excel file with the data contained in the grid.
4. User must not be able to copy the data from the generated file. He should be able to see it without any passwords etc. being asked.

So, to solve the above problems, I have made a VB program. I have successfully achieved the first three objectives. For the requirement number four, I am using the following code:

Expand|Select|Wrap|Line Numbers
  1.     wksReport.Protect "something_secret"
  2.     wksReport.EnableSelection = xlNoSelection
The above code does protect the sheet and does not allow the user to select any cells. After that I am closing the workbook and here comes the problem into picture.

Actually when I am reopening the file (not programatically, just by double clicking the file), the sheet still is protected but user can very easily select the cells and copy them to a new sheet, thereby defeating the purpose of security and requirement number four.

My doubt is that the EnableSelection property is not persisting when the file is closed and is set to its default value when the file is reopened.

Kindly throw some light on this.

Thanks in anticipation.
Jan 8 '08 #1
16 2514
Killer42
8,435 Expert 8TB
I don't know much about it, but I have one question. When you refer to "closing" the file after setting the protection - are you saving it?
Jan 8 '08 #2
QVeen72
1,445 Expert 1GB
Hi,

Not sure of this , but the coding Sequence should be in reverse order (Check Excel Help):

Expand|Select|Wrap|Line Numbers
  1. wksReport.EnableSelection = xlNoSelection
  2. wksReport.Protect "something_secret"
  3.  
and as Killer said, dont forget to save the sheet before quitting..

Regards
Veena
Jan 8 '08 #3
I am definitely saving the file before closing it.

Also, I have tried it both the ways, i.e., first protect then setting EnableSelection property and vice-versa. Actually it doesn't matter what you do first beacuse I am anyway saving the file before closing it. So every operation on the workbook should get saved.

Any other expert can show me the way???
Jan 9 '08 #4
Is anybody there to help me out on this?
Jan 10 '08 #5
Killer42
8,435 Expert 8TB
Ahah! Pretty sure I found your answer. MS acknowledge the problem, and have a workaround, though not really a solution.

See Some of the properties of worksheets are not preserved in Excel
Jan 11 '08 #6
Ahah! Pretty sure I found your answer. MS acknowledge the problem, and have a workaround, though not really a solution.

See Some of the properties of worksheets are not preserved in Excel
I read the article and got your point. But now, is there any other way to achieve my requirement number four.

I cann't put macros in programatically generated excel files beacuse they are hundreds in number and also many people keep macros disabled for security reasons.
Jan 11 '08 #7
Killer42
8,435 Expert 8TB
I read the article and got your point. But now, is there any other way to achieve my requirement number four.

I cann't put macros in programatically generated excel files beacuse they are hundreds in number and also many people keep macros disabled for security reasons.
With MS effectively throwing up their hands in defeat, I don't see how it could be done. I only glanced at the article - there was no patch or anything?

The only other alternatives I can think of are...
  • Use a different spreadsheet program instead of Excel.
  • Display the data in your own program, rather than using spreadsheet.
  • Use your program to drive Excel for display purposes, and do what the macro might not be able to do.
Jan 11 '08 #8
With MS effectively throwing up their hands in defeat, I don't see how it could be done. I only glanced at the article - there was no patch or anything?

The only other alternatives I can think of are...
  • Use a different spreadsheet program instead of Excel.
  • Display the data in your own program, rather than using spreadsheet.
  • Use your program to drive Excel for display purposes, and do what the macro might not be able to do.

All of your alternatives are useless for me as my client requirements are fixed and have been mutually agreed between us months back. It will be something like taking up the challenge and then stepping backward saying that I didn't know that it is not possible using Microsoft Technologies.
Jan 12 '08 #9
QVeen72
1,445 Expert 1GB
All of your alternatives are useless for me as my client requirements are fixed and have been mutually agreed between us months back.
Instead of saying "useless",
How about using some good words like "Does not fulfill my requirement"...?
when some one is trying to help you out be generous in action..
Jan 12 '08 #10
Killer42
8,435 Expert 8TB
Instead of saying "useless",
How about using some good words like "Does not fulfill my requirement"...?
when some one is trying to help you out be generous in action..
Never mind.

vikas000000a, I just don't see how it can be done within the given restrictions. You are apparently stuck with MS Excel as the tool that must be used. MS say Excel cannot do it. What do you want from us?

Perhaps upgrading Excel would resolve the issue - I don't know.

Hm...

Just how "fixed" are the requirements? Perhaps you could password-protect the worksheet so it can only be opened by your program. Your program could then simply open it using the password you've built in, and set the protection on. Then you let the users go ahead with whatever they want to do. Does that sound feasible?
Jan 13 '08 #11
Instead of saying "useless",
How about using some good words like "Does not fulfill my requirement"...?
when some one is trying to help you out be generous in action..
Sorry QVeen72, I never did intend to offend you. It was a general slip of tongue. Take it easy just like the other person 'who actually is trying to help me' did.
Jan 14 '08 #12
Never mind.

vikas000000a, I just don't see how it can be done within the given restrictions. You are apparently stuck with MS Excel as the tool that must be used. MS say Excel cannot do it. What do you want from us?

Perhaps upgrading Excel would resolve the issue - I don't know.

Hm...

Just how "fixed" are the requirements? Perhaps you could password-protect the worksheet so it can only be opened by your program. Your program could then simply open it using the password you've built in, and set the protection on. Then you let the users go ahead with whatever they want to do. Does that sound feasible?
Hello Killer,
Thanks for your kind of support. But the fact remains that my problem is still unresolved. I will further explore it on other sites.

Meanwhile, I found one hole in the wall. It is that if you make an excel file as usual (I mean, not programmatically), and then protect it with disallowing the the selection of cells, when you close and reopen the file, it does remain persisted as it is (the way I want it to be).

I think, I can somehow or the other make use of this fact. Although, I am not still very sure about it.

Anyway, thanks again.
Jan 14 '08 #13
Killer42
8,435 Expert 8TB
Hello Killer,
Thanks for your kind of support. But the fact remains that my problem is still unresolved. I will further explore it on other sites.
Sorry we couldn't help more. If you do find an answer, I'm sure we'd all appreciate your letting us know. That will help anyone else who comes looking for the info in future.

Meanwhile, I found one hole in the wall. It is that if you make an excel file as usual (I mean, not programmatically), and then protect it with disallowing the the selection of cells, when you close and reopen the file, it does remain persisted as it is (the way I want it to be).
Now that is interesting! I wonder how that came about. The automation interface must be failing to set something that the "real" application does.

Maybe there is some way you can take advantage of it. For example, after you turn on the protection, perhaps you could display the spreadsheet and tell Windows that the user pressed Ctrl-S or something. A lot would depend on whether the bug is in the setting of the protection, or the save. The save seems more likely though, since you said that the protection works until the file is reopened.
Jan 15 '08 #14
Sorry we couldn't help more. If you do find an answer, I'm sure we'd all appreciate your letting us know. That will help anyone else who comes looking for the info in future.

Now that is interesting! I wonder how that came about. The automation interface must be failing to set something that the "real" application does.

Maybe there is some way you can take advantage of it. For example, after you turn on the protection, perhaps you could display the spreadsheet and tell Windows that the user pressed Ctrl-S or something. A lot would depend on whether the bug is in the setting of the protection, or the save. The save seems more likely though, since you said that the protection works until the file is reopened.
I would certaily let the forum know when I encounter with the solution.
Jan 15 '08 #15
Sorry we couldn't help more. If you do find an answer, I'm sure we'd all appreciate your letting us know. That will help anyone else who comes looking for the info in future.

Now that is interesting! I wonder how that came about. The automation interface must be failing to set something that the "real" application does.

Maybe there is some way you can take advantage of it. For example, after you turn on the protection, perhaps you could display the spreadsheet and tell Windows that the user pressed Ctrl-S or something. A lot would depend on whether the bug is in the setting of the protection, or the save. The save seems more likely though, since you said that the protection works until the file is reopened.

Hey Killer,
I got the solution of my problem. I installed MS Office 2007 and run the same program without any modification at all. Now the excel files are protected as I wanted them to be. As I have to give only the output excel files to the users, it doesn't bother me if the end user has got Office 2007 or not.

Finally, I did it man.
Feb 8 '08 #16
I had exactly the same problem with Excel 2002.
With Excel 2003 the macrocode works as intended, meaning that NoSelection persists after Close.
When I open the worksheet manually the protected cells can not be selected. That goes for the entire worksheet.
In addition to that I also hide the columns where I have my protected cells..
Feb 23 '09 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Citoyen du Monde | last post by:
Trying to get some ideas on a simple javascript project (to teach myself the language). I want to develop a client-side vocabulary practice application that would allow users to enter their own...
0
by: SK | last post by:
The Excel object that i created in my ASP.Net application is not get destroyed even after session is closed.In the code i have tried methods like .Quit,Marshal.ReleaseComObject etc to kill the...
9
by: Clive Moss | last post by:
Anyone help a beginner at VBA please? I am trying to find a way to use a variable throughout an application. I want to take the value from a log-in form (the user) and use it in most forms...
1
by: L Mehl | last post by:
A process presents frmSecond for user entry; user closes when done. Code for opening the form is DoCmd.OpenForm "frmSecond", acNormal, , strWHERE, , acDialog Problem: frmSecond does not...
4
by: Dave Veeneman | last post by:
When does serializing objects make more sense than persisting them to a database? I'm new to object serialization, and I'm trying to get a feel for when to use it. Here is an example: I'm...
1
by: lim | last post by:
What is the possible error that occurs when the Page_load event is not triggered during execution. In my page there's some basic server control. Is there any loops holes?
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
4
by: bozzzza | last post by:
Hi All, We have a busy website, and I was wondering if we should persist the data by storing the data table in a session or cookie, and when the user re-loads the page I can cast the session or...
0
ADezii
by: ADezii | last post by:
Most Access Users realize that Recordsets, being virtual representations of a Query, Table, or SQL Statement, exist only in our PC's memory. They, and the data they contain, literally exist at one...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.