2007 VBA Code in 2010 Gives Multiple Errors: Runtime Error 91 and more

VbANewbie13

New Member
Joined
Dec 9, 2011
Messages
8
Good morning Experts!

I am in much need of your assistance. Please bear with me as I am still learning :) :confused:

I have a Excel Form that was developed in 2007 and we have now migrated to 2010 and the form is throwing many errors that I am unable to pinpoint the issues. To name a few: Runtime Error 91, Not Creating/Saving in Desktop Folder, Runtime error 91, when new unedited file is opened the Calendar Class not allowing me to select today's date (showing as 00 Jan 1900 when selecting today's date). To further explain:

PROBLEM #1 ::::

Upon opening the form (and once 'Enable Editing' button is clicked), I receive a Run-time error '91': Object Variable or With block variable not set and the Debugger points out the following line:

Code:
ActiveWindow.DisplayWorkbookTabs = False

Below is the whole block of code located on ThisWorkbook:

Code:
Private Sub Workbook_Open()
    ActiveWindow.DisplayWorkbookTabs = False
    
    If Sheets("Sheet2").Visible = True Or Sheets("Emails").Visible = True Or Sheets("Help").Visible = False Then
        ThisWorkbook.Unprotect Password:="password"
        Sheets("Sheet2").Visible = False
        Sheets("Emails").Visible = False
        Sheets("Help").Visible = True
        ThisWorkbook.Protect Structure:=True, Windows:=False, Password:="password"
    End If
    
    'ThisWorkbook.Protect Structure:=True, Windows:=False, Password:="password"
    
    'Check to see if CANN Requests folder exists on Desktop
    If Len(Dir(Environ("userprofile") & Application.PathSeparator & "Desktop" & Application.PathSeparator & "Requests", vbDirectory)) = 0 Then
        'If not then create it
        MkDir Environ("userprofile") & Application.PathSeparator & "Desktop" & Application.PathSeparator & "Requests"
    End If
  
  
End Sub

PROBLEM #2 :::
When the original form is opened (and 'Enable Editing' button is clicked), it should also check to see if the /Requests/ folder is on the desktop and if not create the folder. This functionality is broken also.

PROBLEM #3 :::
Once the form is submitted by the original requestor, the form content becomes locked, and the form is sent via email to the next level for approval. The next Runtime Error 91 occurs when the approver opens the file from the email and selects 'Enable Editing'. Runtime Error 91: Object Variable or With block variable not set

PROBLEM #4 :::
When originally created the form contained 2 calendars based on the calendar control/date picker avail in 2007. As you know 2010 does not include a calendar control/date picker (my users are with SP1 and no admin rights on machines to D/L or register the new control 11.0 avail with SP4). In researching I found a Calendar Class solution that works with one small issue, it will not allow me to select today's date. When todays date is selected it places 00 jan 1900 in the field designated for the date. I thought that I had migrated everything from the 2007 Calendar Control to using the new Calendar Class, but must have done something wrong....(this is the Calendar Control Class that I integrated: https://sites.google.com/site/e90e50/calendar-control-class[/URL] )

This is the code on my UserForm1:

Code:
Option Explicit
'UserForm with Frame1
Private WithEvents Calendar2 As cCalendar
Private Sub Frame1_Click()
End Sub
Private Sub UserForm_Initialize()
    Set Calendar2 = New cCalendar
    
        With Calendar2
        .HeaderBackColor = "&H80000000"
        .SaturdayBackColor = "&H80000002"
        .SundayBackColor = "&HFFAA99"
        .DayFont = "Avant Garde"
        .GridFont = "Avant Garde"
        .TitleFont = "Arial Black"
        .TitleFontColor = "&H80000011"
    End With
    
    Calendar2.Add_Calendar_into_Frame Me.Frame1
End Sub
Private Sub UserForm_Activate()
    Calendar2.Value = Range("F4")
End Sub
Private Sub Calendar2_DblClick()
    Sheet1.Unprotect Password:="password"
        Range("F4") = Calendar2.Value + Time
    Sheet1.Protect Password:="password"
Unload Me
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    Set Calendar2 = Nothing
End Sub

Any assistance would be greatly appreciated and I hope that I have provided enough information and posted correctly, if not, please let me know and I will do what I can to help/correct.

THANK YOU!!!

VbANewbie13
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,215,133
Messages
6,123,233
Members
449,092
Latest member
SCleaveland

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