Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default 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
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
Error 1004, Application-definded or object-defined error Mirco Wilhelm[_2_] Excel Programming 9 January 7th 06 04:56 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Run time error '1004': Generaol ODBC error Dwaine Horton[_3_] Excel Programming 2 April 26th 05 02:52 PM


All times are GMT +1. The time now is 12:59 AM.

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

About Us

"It's about Microsoft Excel"