> I don't know why you are so concerned about the file names. My method works
> with any valid filename and will work with any number of opened files.
[quoted text clipped - 88 lines]
> > > > > > MsgBox "File Saved to " & myFileName
> > > > > > End If
I have thought about your problem a lot. Diasabling the button is a good
idea but it is not fool-proof. Somebody on another PC could open the file
and you would not cause the button to be disabled.
You need to assign a unique filename to each button. Button will only be
enabled when the filename corresponding to the button doesn't exist.
The fool-proof method is when the button is clicked to check the files in
the folder to make sure the file doesn't exist and create a new file
immediately so two people aren't working with temporary files with the same
name.
You can use a workbook open function to check if the files exist in the
folder and disable the buttons for files that already exist when the workbook
is opened.
If you need to keep track of the number of opened files you can add a count
to my code to count the files.
> Well I haven't tried your code but my thinking is lets say there are 15
> workbooks in the same folder and they open CSB 1257 Reports 12, CSB 1257
[quoted text clipped - 96 lines]
> > > > > > > MsgBox "File Saved to " & myFileName
> > > > > > > End If
jnf40 - 25 Sep 2007 19:40 GMT
here is some of what I have
Private Sub Workbook_Open()
UnhideSheets
End Sub
Private Sub UnhideSheets()
Dim sht As Object
Dim f As Worksheet
Application.ScreenUpdating = False
ActiveWorkbook.Unprotect Password:="csb"
If ThisWorkbook.Sheets.Count = 15 Then
Call Module1.macro3
ElseIf ThisWorkbook.Sheets.Count > 5 Then
For Each sht In ThisWorkbook.Sheets
sht.Visible = xlSheetVisible
If sht.Name <> Sheets("Macros").Name And sht.Name <> Sheets("CSB
Form 12572").Name _
And sht.Name <> Sheets("Create Pay Report").Name And sht.Name <>
Sheets("CSB Form 1257").Name _
And sht.Name <> Sheets("Manhole Inlet").Name Then
sht.CommandButton2.Enabled = True
If sht.CommandButton1.Visible = True Then
sht.CommandButton1.Enabled = True
End If
End If
sht.Protect Password:="csb", _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
UserInterfaceOnly:=True
sht.EnableSelection = xlUnlockedCells
Next sht
For Each f In ActiveWorkbook.Worksheets
If f.Name = Sheets("Create Pay Report").Range("wksname") Then
f.Select
Exit For
End If
Next f
ThisWorkbook.Sheets("Create Pay Report").Visible = False
ThisWorkbook.Sheets("Macros").Visible = False
ThisWorkbook.Sheets("CSB Form 1257").Visible = False
ThisWorkbook.Sheets("CSB Form 12572").Visible = False
ThisWorkbook.Sheets("Manhole Inlet").Visible = False
ElseIf ThisWorkbook.Sheets.Count = 5 Then
For Each sht In ThisWorkbook.Sheets
sht.Visible = xlSheetVisible
sht.Protect Password:="csb"
Next sht
ThisWorkbook.Sheets("Macros").Visible = False
ThisWorkbook.Sheets("CSB Form 1257").Visible = False
ThisWorkbook.Sheets("CSB Form 12572").Visible = False
ThisWorkbook.Sheets("CSB Form 12572").Visible = False
ThisWorkbook.Sheets("Manhole Inlet").Visible = False
ActiveSheet.Cells(19, 26).Select
ActiveSheet.Protect Password:="csb", _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
UserInterfaceOnly:=True
ActiveSheet.EnableSelection = xlUnlockedCells
End If
Application.ScreenUpdating = True
ThisWorkbook.Protect Password:="csb"
End Sub
Module1 Macro3 loads a userform which has the commandbutton1 on it I am
trying to disable. This would only occur if they open a workbook that was
earlier than the latest one created.
> I have thought about your problem a lot. Diasabling the button is a good
> idea but it is not fool-proof. Somebody on another PC could open the file
[quoted text clipped - 115 lines]
> > > > > > > > MsgBox "File Saved to " & myFileName
> > > > > > > > End If