If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Unable to open excel sheet in Protected mode from VB 6.0

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-26-05, 06:36
ourspt ourspt is offline
Registered User
 
Join Date: Jan 2005
Posts: 33
Unable to open excel sheet in Protected mode from VB 6.0

Hi,

I am working on a project in VB6.0 and SQL Server. We use MS Excel for our reports. We also

use server side COM+ components.

We have a situation where we are not able to open some of the reports in 'protected' mode

(i.e, to prevent the users from making changes to the excel report). When we try to open

these in protected mode, the application is crashing, giving a Dr. Watson error.

When we change the VB code to open the excel reports in 'Unprotected' mode, the applcation

works alright. But in this case, the users would be able to change the reports as they like.

Why am I not able to open these excel reports in protected mode from my VB6.0 exe?

Is there a way, where we can prevent the users from making changes to the excel report, even

if we open it in 'unprotected' mode?

We tried using the 'Read Only Recommended' option but that allows the users to make changes

and save changes as some other file name (although the users are prevented from making

changes to the same file) and this cannot be allowed in our application.

Any help in this regard is greatly appreciated.

Thanks in advance
ourspt
Reply With Quote
  #2 (permalink)  
Old 01-26-05, 06:52
DavidCoutts DavidCoutts is offline
Registered User
 
Join Date: Jan 2004
Location: Aberdeen, Scotland
Posts: 1,067
if your allowed to put code into your workbook
try putting this event into it

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
End Sub

this will stop the workbook being saved
you can then have your read only property set so no changes can be made

HTH
Dave
Reply With Quote
  #3 (permalink)  
Old 09-16-09, 14:07
puneet_july30 puneet_july30 is offline
Registered User
 
Join Date: Dec 2008
Posts: 2
Hi
Is there any way to write this code to excel from VB6
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
End Sub
Actually my problem is

I have an application written in Visual Basic 6. My application
creates a Customer Details Report in Excel. All done till here but now
my problem is that I want to prevent the users from making changes to
the excel report or to copy/paste/delete data from my report or to
save file as another name.
I tried protecting the sheet but that only solves half of the problem,
user can still save file as another name and copy the data.

Use of macro is strictly not allowed.

Please Help
Thanks in Advance
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On