Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old September 11th, 2003, 06:33 AM
steve007 steve007 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: uk
Posts: 8 steve007 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Workbook Access Problem

I have a problem,
i have made a program that writes data to an excel file, the process takes approx 1 hour but will increase due to more data being written, the problem is that while this program is running a user can open any excel document on thier drive and the workbook that my program is using (writing data to) opens up with that file. I do not want any access to the workbook that is being written to, i want to somehow lock access, deny access, or hide the workbook so no matter what excel file you open - it wont let the workbook my program is working on open with it. Basically i want my program to compile an excel file in the background but at the same time a user can open any excel document close it, and open another without mine opening at all until the proceedure is complete.
Any ideas how i can fix this issue? I have already tried starting new excel, saving the workbook as something else then re-opening it but not so its visible and it works as long as you dont open another excel file. if the workbook is open like this shouldnt it bring up a msgbox saying file in use and give an option to read only??? it dont though.

Thanks

Reply With Quote
  #2  
Old September 13th, 2003, 07:08 AM
ajmh ajmh is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 19 ajmh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm not sure this will work, but have you tried password protecting the file that you are making? If you set a password before you write the data, then remove it after the process has completed then it should remain "locked" from other people (probably...)

Reply With Quote
  #3  
Old September 14th, 2003, 08:28 AM
steve007 steve007 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: uk
Posts: 8 steve007 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i Have tried that and it still doesnt work, its because the workbook is opend by the program already so it can write data to it, so a password wud not make any difference. i need a way of hiding the workbook or making it visible = false. Im not sure how to do that. since my program writes so much data to the excel file (about 500,000 to 1million rows of data - spans across sheets) if the user does open the workbook by mistake or access it and happens to write any data to it then the program crashes coz of an application error (prob coz its accessing an activesheet and this has changed when the workbook is visible to the user) so it needs to be hidden away somehow. this is soo frusrating.

Last edited by steve007 : September 14th, 2003 at 08:31 AM.

Reply With Quote
  #4  
Old September 14th, 2003, 11:16 AM
ajmh ajmh is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 19 ajmh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hmmm... There must be some even which takes place at the start of a new instance of the application - maybe you can get it to hide your workbook from the active workbooks menu (Window list).

Otherwise it might be a case of subclassing Excel and removing the menu item using winAPI... but that's not a good way to go if you can avoid it.

I'll see what I can find out, but I've just mucked up my Office installation, so it might take a while...

Reply With Quote
  #5  
Old September 14th, 2003, 11:44 AM
steve007 steve007 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: uk
Posts: 8 steve007 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hiding it from the menu may well work, i will give it a try soon, however im jsut thinking about the user - a user of a program is incredibly stupid, (thats what my teacher said) so ya have to prepare for anything to make a stable rigid program.......what if the user tries to unhide it? thats if this works of course. can i make the application invisible? if i can could it be made visible by the user???

Reply With Quote
  #6  
Old September 15th, 2003, 01:04 AM
ajmh ajmh is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 19 ajmh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You can make the application invisible when you kick off an instance of it, but if they open it up via the normal shortcut then, as you have found, it will run up a copy and (usually) display the workbook...

You might do well by having the program / macro display a nice big message warning telling the user NOT TO TOUCH anything while your process is running (in conjunction with hiding the workbook), and if you have any idea of the total amount of (a) time or (b) number of records/rows you have to process then you could display a progress bar - always a feature I appreciate when running long processes.

Reply With Quote
  #7  
Old September 15th, 2003, 03:14 AM
George1111 George1111 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: AUSTRALIA
Posts: 3 George1111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
While you cannot stop a user from running Excel (if it exists), you can stop them getting into a Worksheet.
If your VB program opens the Workbook as unshared - by opening an existing workbook name (even if it is blank), then when a user tries to run Excel, they get to see the title bar only, but excel will not run for them. (It acts as though it is locked up)
This has been my experience.
Look at the task list when you attempt to open a second occurance of excel and normally you will see the 2nd occurence there - this is the only way I have found to terminate the second occurance is to terminate the task here.

Hope you find that helpful.

Reply With Quote
  #8  
Old September 15th, 2003, 06:34 AM
steve007 steve007 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: uk
Posts: 8 steve007 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The best way I could resolve it is if i can write to the file without it being open at all lol. hmmm dont think its possible. I blame Microsoft entireley of course since they made it all. As to the progress bar, i do have one on my program showing how long it will take (as you can imagine 500,000 to 1million records can take a very long time to process) therefore hoggin the cpu useage and blocking access to Excel for that length of time, which is not good since the main program used at any time is Excel. Even if a user opend a new instance of Excel it still would not work since my program writes to the activesheet, and of course if a new instance is opend then it will write data to the activesheet in that wouldnt it? so either way im very stuck on this problem. Dunno if you guys can help but i also had a topic about "Cell Values" on the forum but no-body responed yet - wonder if either of you know how to help me on that (im thinking if i can resolve one problem here im half way there lol)

Thank you very much.

Reply With Quote
  #9  
Old September 15th, 2003, 09:28 AM
ajmh ajmh is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 19 ajmh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Have you considered writing the data out to a flat file like *.csv ?? Then you would only have to kick off Excel to import the data - probably significantly faster than continuously passing messages to Excel to handle from VB - and you then don't have to worry about users messing around at the same time...

Reply With Quote
  #10  
Old September 15th, 2003, 10:07 AM
saxtonj saxtonj is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 11 saxtonj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 32 sec
Reputation Power: 0
Can you not make the file Locked (I.e read-only) when you open it?

If you are using the excel object 8.0 within VB then I don't see why you can't do this.

that way if someone opens it, they cna change whatever they like, they wont be able to save it because it opens as read only.

Reply With Quote
  #11  
Old September 16th, 2003, 12:01 AM
George1111 George1111 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: AUSTRALIA
Posts: 3 George1111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This example will allow you to write to BIFF format (Excel Format).
It processes about 100 times faster than using an Excel Object!
Attached Files
File Type: zip excelclass.zip (47.4 KB, 285 views)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Workbook Access Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway