"Activeworkbook" function not valid when workbook embedded in Lotus Notes?

P

Punsterr

I have an Excel workbook that has a workbook_open() sub that maximizes
the screen and password-protects all of the worksheets. This sub works
fine when I save the file on my hard drive or on the network.

However, when I embed the file in a Lotus Notes database, the macro
immediately errors out on the first line of code
(ActiveWorkbook.Unprotect Password:="Password"). It's as if the file
is no longer recognized as an Excel file.

Any thoughts on how I should rewrite this so that it works both when
saved on a network and in Lotus Notes?

Sub Workbook_Open()

'I put in this first line of code to find out what the activeworkbook
name was upon opening from Lotus Notes. It still errors out (works
fine saved on the network).

MsgBox "The name of the active Workbook is " &
ActiveWorkbook.Name
MsgBox "The name of the active Sheet is " & ActiveSheet.Name

' Maximize all windows

ActiveWorkbook.Unprotect Password:="Password"
Application.WindowState = xlMaximized
ActiveWindow.WindowState = xlMaximized
ActiveWorkbook.Protect Password:="Password", Structure:=True,
Windows:=True

' Opens workbook to Table of Contents cell A1 upon opening the
workbook.

Sheets("Contents").Select
Range("a1").Select


' Show splash screen upon opening the workbook

SplashForm.Show

' Password-protect all worksheets but lets macros hide/delete

Application.ScreenUpdating = False
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:="Password",
userinterfaceonly:=True, AllowFormattingCells:=True,
AllowFormattingColumns:=True, AllowFormattingRows:=True
ws.EnableSelection = xlNoRestrictions
Next ws
Application.ScreenUpdating = True

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top