Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Opening and Closing workbooks in code

The only people who will get the password to the workbooks for the data will
be admin. All other people will use the excel userforms. I will lock the code
and add passwords for the databook.

I know I need to add the password part to the code.

That would only leave if the code breaks to cause the problem you described.
--
Regards and Thanks for any assistance.

Francis Brown.


"Rowan Drummond" wrote:

Hi Francis

Happy to help.

Without actually testing your code it looks like you could get into a
very long loop eg if somebody else has the file open for an hour (or all
day!!) this looks like it will continue to open and close the file as
read only until the other user closes it?

Regards
Rowan

Francis Brown wrote:
Hello.

Thanks for answer. It worked with slight alteration. Thanks for getting me
on right track.

heres my code :

Private Sub CommandButton1_Click()

Do Until issave = True
Dim theBk As Workbook
Set theBk = Workbooks.Open("Z:\Systemdown\Declaration.xls")
If theBk.ReadOnly Then
theBk.Close False
issave = False
Else
newrow =
Workbooks("Declaration.xls").Sheets("data").Range( "A65536").End(xlUp).Row + 1
Workbooks("Declaration.xls").Sheets("data").Cells( newrow, 1).Value
= TextBox1.Value
Workbooks("Declaration.xls").Sheets("data").Cells( newrow, 2).Value
= TextBox2.Value
Workbooks("Declaration.xls").Sheets("data").Cells( newrow, 3).Value
= TextBox3.Value
Workbooks("Declaration.xls").Sheets("data").Cells( newrow, 4).Value
= TextBox4.Value

theBk.Close True
MsgBox "Records Saved"
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
issave = True

End If
Loop

End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing workbooks w/o closing Excel Barb in MD Excel Discussion (Misc queries) 3 February 15th 10 06:42 PM
Disabling formula recalculation when opening or closing workbooks Joe Excel Discussion (Misc queries) 3 August 5th 08 09:24 PM
Opening/Closing workbooks without dialog boxes Steve :) Excel Programming 2 September 20th 05 09:37 PM
Error when closing workbooks after running .net code Stefan Hojnowski Excel Programming 1 August 6th 05 04:16 AM
Opening and Closing workbooks Jase Excel Programming 1 October 15th 03 06:28 AM


All times are GMT +1. The time now is 02:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"