473,394 Members | 1,946 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,394 software developers and data experts.

Allow spreadsheet to be opened max of 10 times

Hello,
I am new to this forum and new to Visual Basic.
I need someone to point me in the right direction.

I have been asked to write a spreadsheet (which I have done) and then use a macro which will run everytime the file is opened, which will only allow the user to access the spreadsheet 10 times.

This is what I have so far.
-----------------------------------------------

Dim counter As Integer


Sub Auto_open()
'
' Macro to limit use of spreadsheet to 10 times
'
counter = 10

If counter > 0 Then
userResponse = MsgBox("this application is limited to 10 uses. You have <counter> uses remaining", vbOKOnly, "Warning")

'I don't know what the format is for showing the counter value is.


counter = counter - 1
'When counter = 0, do not allow access to spreadsheet

Else end programme and block user from opening spreadsheet
End Sub

Apologies if this is not the correct place to ask this question.

Many thanks
Aston
Oct 26 '07 #1
2 1029
jamesd0142
469 256MB
Expand|Select|Wrap|Line Numbers
  1. Dim counter As Integer
  2.  
  3.  
  4. Sub Auto_open()
  5. '
  6. ' Macro to limit use of spreadsheet to 10 times
  7. counter = 10
  8.  
  9. If counter > 0 Then
  10. userResponse = MsgBox("this application is limited to 10 uses. You have "&counter&+" uses remaining", vbOKOnly, "Warning")
  11.  
  12. 'I don't know what the format is for showing the counter value is.
  13.  
  14.  
  15. counter = counter - 1
  16. 'When counter = 0, do not allow access to spreadsheet
  17.  
  18. Else end programme and block user from opening spreadsheet
  19. End Sub
  20.  

should this line 'If counter > 0 Then' be 'If counter > 10 Then' ???

ignore my above comment read the code wrong :)
Oct 26 '07 #2
darrel
72
i think this is the right condition "If counter < 0".
Oct 27 '07 #3

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

Similar topics

2
by: quadric | last post by:
Hi, I have an application that requires that Python initiate and mediate a live and iterative conversation between an external application (in which Python is embedded) and an external Excel...
2
by: Fabio | last post by:
Hello, there's a module called Spreadsheet::WriteExcel. It allows me to create a new worksheet and edit its cells: my $workbook = Spreadsheet::WriteExcel->new('my.xls'); my $worksheet =...
6
by: Topmind | last post by:
If the Windows Web browser (IE 5 or 6) opens an XLS file (spreadsheet), how it handles it depends on a file association setting within Windows. There is a setting called "confirm open after...
1
by: jquest | last post by:
Hi; I have a database that keeps track of customers and work done for them. Some customers are repeat customers many times over, ie more than 100 records for them. I keep track of them in the...
69
by: RC | last post by:
I know how to do this in JavaScript by window.open("newFile.html", "newTarget", "scrollbars=no,resizable=0,width=200,height=200"); The browser will open a new window size 200x200, not allow...
7
by: rdemyan via AccessMonster.com | last post by:
I want to make sure that I'm closing an opened spreadsheet correctly. I've been having some locking up problems. The following code adds a dummy row to the spreadsheet to ensure that that the data...
2
by: crimestarter.jim | last post by:
Good afternoon, I am not the most informative when it comes to Microsoft Access. I have a user that is using Access 2003 and has 1 excel spreadsheet linked to 3 different databases. They are...
0
by: Bob Alston | last post by:
It appears that when Access opens the link to an Excel spreadsheet, it uses an exclusive lock. Understandable if you want updatability. However, I have a client with need for Excel data in a read...
2
by: edgalljr | last post by:
I have Access 2000 programmed to run a very simple code to run a query and OutputTo an Excel spreadsheet: DoCmd.OutputTo acOutputQuery, "XLS Applicants", acFormatXLS, "C:\My RMBC...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.