Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with 1004 Error
I am very new to vba and have an issue with a 1004 error when the
workbook is located on a shared drive and more than 1 user opens the file. My question is if it is possible to make it so: a) the user cannot overwrite when another user is editing the file. b) how to get rid of the 1004 debug or end error when a user closes the file. I tried taking out Active Workbook.save in the Private Sub Workbook_BeforeClose, but when I do that, I loose the functionality of the code. Any help would be most appreciated. Private Sub Workbook_Open() Application.ScreenUpdating = False FrontpageFirst On Error Resume Next sStr = fOSUserName() x = sStr Select Case x Case "pmason" Worksheets("Summary").Visible = True Worksheets("Key to Abbrvs").Visible = True Worksheets("Open Positions").Visible = True Worksheets("Filled Positions").Visible = True Worksheets("Declined Offers").Visible = True Worksheets("Current TTRs").Visible = True Worksheets("Current TOs").Visible = True Worksheets("On Hold").Visible = True Case Else For i = 2 To Worksheets.Count Worksheets(i).Visible = xlVeryHidden Next End Select Worksheets(2).Activate Worksheets(1).Visible = xlVeryHidden Application.ScreenUpdating = False End Sub Sub FrontpageFirst() Dim page As String page = "Unauthorized" On Error Resume Next Worksheets(page).Visible = True If Worksheets(1).Name = page Then Worksheets(1).Activate Else Worksheets(page).Activate If Err = 0 Then ActiveSheet.Move befo=Worksheets(1) Else Worksheets.Add befo=Worksheets(1) Worksheets(1).Name = page End If End If End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) FrontpageFirst For i = 2 To Worksheets.Count Worksheets(i).Visible = xlVeryHidden Next Application.DisplayAlerts = True ActiveWorkbook.Save Application.DisplayAlerts = False End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Error 1004, Application-definded or object-defined error | Excel Programming | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) | |||
Run time error '1004': Generaol ODBC error | Excel Programming |