Userform throwing a 438 error on hiding workbook

AMoss79

New Member
Joined
Jan 7, 2016
Messages
4
Hi all,
Hope you can Help i'm fairly new to VBA and Userforms.

We have a userform which we want filling in but don't want to show the excel in the background as we want to try limit anyone from going in and updating it, this works fine if there are no other workbooks open but if there is the code i have currently is causing a runtime 438 error

It's being opened from sharepoint and we have had a few instances were data isn't being saved as it's opened in read only hence the code to open in edit mode.

here is the code I have (i've highlighted the line debug is showing me as being at fault in red)

/**************************************************/

Private Sub Workbook_Open()
Application.DisplayAlerts = False

If ActiveWorkbook.ReadOnly = True Then
ActiveWorkbook.LockServerFile
End If

If Workbooks.Count > 1 Then 'if more than 1 excel instance open
Workbooks("ExcelUserformName.xlsm.").Visible = False ' hide the workbook
Else
Application.Visible = False ' hide the excel for userform
End If

Userform1.Show 'show the Userform


End Sub

Any Advice would be appreciated. This is hopefully the last hurdle to haveing a nicely functioning userform
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top