Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-10-2013, 01:23 PM
beginner beginner is offline Workbook_Open event do not working? Windows 7 32bit Workbook_Open event do not working? Office 2007
Advanced Beginner
Workbook_Open event do not working?
 
Join Date: Sep 2011
Location: Europe
Posts: 45
beginner will become famous soon enough
Question SOLVED: Workbook_Open event do not working?

On this link I wrote about my problem and I attach my file *. Xlsm
When I save my Workbook as *. Xlsm in this case Workbook_Open event is functioning correctly.
If I save in the file format *. Xls, in this case on re-opening the file Workbook_Open event that does not work, nothing happens?

I tried to run the file in *. Xls format and after that nothing happens I've tried to run the following VBA code to check the event

Code:
Sub EnableEventsNow()
    Dim sMsg As String
    With Application
        sMsg = IIf(.EnableEvents, _
            "Events were already enabled.", _
            "Events are now enabled.")
        .EnableEvents = True
    End With
    MsgBox sMsg
End Sub
After activating this code (I put the cursor inside the VBA code) by pressing F5 on my keyboard, then I get the message "Events were allready enabled" means that the event has started?



Can someone help me and explain why it is not working Workbook_Open event in *. XLS file format

Improved thanks for any help.

Last edited by beginner; 04-11-2013 at 02:38 PM. Reason: solved problem
Reply With Quote
  #2  
Old 04-10-2013, 02:41 PM
macropod's Avatar
macropod macropod is offline Workbook_Open event do not working? Windows 7 64bit Workbook_Open event do not working? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The issue may be that your Workbook_Open code has content that isn't supported in the xls format. Without seeing the code, it's impossible to say for sure what the issue is.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-11-2013, 01:22 AM
beginner beginner is offline Workbook_Open event do not working? Windows 7 32bit Workbook_Open event do not working? Office 2007
Advanced Beginner
Workbook_Open event do not working?
 
Join Date: Sep 2011
Location: Europe
Posts: 45
beginner will become famous soon enough
Default

Quote:
Originally Posted by macropod View Post
The issue may be that your Workbook_Open code has content that isn't supported in the xls format. Without seeing the code, it's impossible to say for sure what the issue is.
Thanks for answering. I attach my file in XLS format vith VBA code

I tried also a simple VBA in my XLS file (See second attach)
Code:
Private Sub Workbook_Open()
Sheets("Sheet1").Activate
End Sub
but nothing happens

Thank you, that you have a desire to help me
Attached Files
File Type: xls limitdate.xls (38.5 KB, 9 views)
File Type: xls Sheet1_Activate.xls (25.5 KB, 10 views)
Reply With Quote
  #4  
Old 04-11-2013, 02:38 AM
macropod's Avatar
macropod macropod is offline Workbook_Open event do not working? Windows 7 64bit Workbook_Open event do not working? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your 'Sheet1 Active' workbook works fine for me - immediately it is opened it switches from Sheet3 to Sheet1. Same behaviour for both Excel 2010 and Excel 2003.

Your limitdate workbook's macro falls over because you haven't declared the 'limitdate' variable. Furthermore, you don't need the 'Application.EnableEvents = True' code as it does nothing in the context in which you have it.

You have numerous comments in your files about what you're trying to achieve. I don't propose to do your development work for you. However, you might find the following code, which I've posted elsewhere, useful.

The following code works by automatically hiding all except a 'main' worksheet upon opening and closing. It then asks the user for their worksheet name and password. If the correct password for the named sheet is given, it is displayed and unprotected; otherwise the prompt is repeated. If the prompts are left empty, the code does nothing more and exits.

The code is also written around the principle that the workbook itself should be protected - see the relevant comments in the code. This is to protect its structure etc, so that you won't run into problems with sheets being renamed etc.

You may want to add more code to trap 'Save' events, in case the user saves the workbook with their worksheet visible and a subsequent user opens the workbook with macros disabled.
Code:
Option Explicit
Dim User As String, UPwd As String, WPwd As String
Dim Err As Boolean, wsSheet As Worksheet, wsActvSht As Worksheet
Private Sub Workbook_Open()
WPwd = "" 'Inset the Workbook Password between the double quotes
Set wsActvSht = ThisWorkbook.Sheets("Sheet1") ' A worksheet that must remain visible
If ThisWorkbook.ProtectStructure = True Or ThisWorkbook.ProtectWindows = True Then ThisWorkbook.Unprotect WPwd
wsActvSht.Activate
For Each wsSheet In ActiveWorkbook.Worksheets
  With wsSheet
    If .Name = wsActvSht.Name Then
      .Visible = xlSheetVisible
    Else
      .Visible = xlSheetVeryHidden
    End If
  End With
Next wsSheet
Restart:
User = InputBox("Please Input your Worksheet Username")
UPwd = InputBox("Please Input your Worksheet Password")
For Each wsSheet In ActiveWorkbook.Worksheets
  With wsSheet
    If .Name = User Then
      On Error GoTo Restart
      If .ProtectContents = True Then .Unprotect UPwd
      .Visible = xlSheetVisible
      .Activate
      Exit Sub
    End If
  End With
Next wsSheet
ThisWorkbook.Protect Password:=WPwd, Structure:=True, Windows:=True
End Sub
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ThisWorkbook.ProtectStructure = True Or ThisWorkbook.ProtectWindows = True Then ThisWorkbook.Unprotect WPwd
For Each wsSheet In ActiveWorkbook.Worksheets
  With wsSheet
    If .Name = User Then .Protect UPwd
    If .Name <> wsActvSht.Name Then .Visible = xlSheetVeryHidden
  End With
Next wsSheet
wsActvSht.Activate
ThisWorkbook.Protect Password:=WPwd, Structure:=True, Windows:=True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 04-11-2013, 01:09 PM
beginner beginner is offline Workbook_Open event do not working? Windows 7 32bit Workbook_Open event do not working? Office 2007
Advanced Beginner
Workbook_Open event do not working?
 
Join Date: Sep 2011
Location: Europe
Posts: 45
beginner will become famous soon enough
Default

Quote:
Originally Posted by macropod View Post
Your 'Sheet1 Active' workbook works fine for me .......................
You have numerous comments in your files about what you're trying to achieve. I don't propose to do your development work for you.
Thank you for answering and responding
I will not ask you that you developed for me and your wasting your time.

Thank you for this macro code that you gave me. I will examine this VBA code.
For all other problems, I will help look for internet surfing

Forget the comments in my VBE, go to solve this problem based on topic
My Excel or Office 2007 does not correct?
I using Excel 2007 SP3 (12.0.6661.5000)-(12.0.6607.1000)

When I start XLS file format Workbook_Open () does not work.
How do I solve this problem?
What should I do, that I can using XLS file format
Reply With Quote
  #6  
Old 04-11-2013, 01:14 PM
macropod's Avatar
macropod macropod is offline Workbook_Open event do not working? Windows 7 64bit Workbook_Open event do not working? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Have you checked your macro security settings (Developer>Macro Security) to confirm that you can run macros? It should be set to the second option: 'Disable all macros with notification'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 04-11-2013, 01:25 PM
beginner beginner is offline Workbook_Open event do not working? Windows 7 32bit Workbook_Open event do not working? Office 2007
Advanced Beginner
Workbook_Open event do not working?
 
Join Date: Sep 2011
Location: Europe
Posts: 45
beginner will become famous soon enough
Default

Quote:
Originally Posted by macropod View Post
Have you checked your macro security settings (Developer>Macro Security) to confirm that you can run macros? It should be set to the second option: 'Disable all macros with notification'.
I allow all macros in Excel Options
I have set my location "C :/ User / Downloads /" as a Trusted Location




BTW: If I using XLSM format file, then all is OK, Workbook_Open working without problems
Reply With Quote
  #8  
Old 04-11-2013, 01:54 PM
macropod's Avatar
macropod macropod is offline Workbook_Open event do not working? Windows 7 64bit Workbook_Open event do not working? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your security settings are most unwise. You should not use 'Enable all macros' and you should not check the 'Trust access ..' option. With those settings, a macro virus could do a lot of damage to your system.

As for your problems with xls files only, that suggests there may be a problem with your Office installation. Try repairing the Office installation (via Excel Options|Resources|Diagnose).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 04-11-2013, 02:37 PM
beginner beginner is offline Workbook_Open event do not working? Windows 7 32bit Workbook_Open event do not working? Office 2007
Advanced Beginner
Workbook_Open event do not working?
 
Join Date: Sep 2011
Location: Europe
Posts: 45
beginner will become famous soon enough
Default SOLVED: Workbook_Open event do not working?

Quote:
Originally Posted by macropod View Post
As for your problems with xls files only, that suggests there may be a problem with your Office installation. Try repairing the Office installation (via Excel Options|Resources|Diagnose).
Thank you for the idea
MS Office Diagnostics has solved my problem.
Workbook_Open() event is now working

Thanks for Your answers
Reply With Quote
Reply

Tags
workbook_open



Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate event reminders rgarneau Outlook 0 01-23-2012 08:58 AM
Workbook_Open event do not working? Create calendar event groegee Outlook 1 12-05-2011 09:56 PM
Catch event before next slide PetLahev PowerPoint 0 10-21-2011 03:29 AM
Event Log - Outlook Crashed Davva Outlook 0 11-10-2009 01:35 PM
Problem with Workbook_Open with CustomUI birdseye42 Excel 0 08-26-2009 11:59 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:41 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft