Solved

Excel VBA - How to Control Calendar Object from Module

Posted on 2011-02-25
5
369 Views
Last Modified: 2012-05-11
How can I control a calendar from a module (vs. worksheet code)?

I want to toggle a calender property     .visible = true/false from a module.

script:        Calendar1.visible=true        

works fine in the worksheet, but bugs out at the module level.
0
Comment
Question by:AndresHernando
  • 2
5 Comments
 
LVL 41

Accepted Solution

by:
dlmille earned 500 total points
ID: 34993675
An excel Calendar object is a Shape.

The below code provides two routines - one to make visible, and one to make invisible.  The assumption is there's a calendar called "Calendar1" in Sheet1.  This can be placed in a public module.

Sub CalendarVisible()

    Sheets("Sheet1").Shapes("Calendar1").Visible = True

End Sub
Sub CalendarInvisible()

    Sheets("Sheet1").Shapes("Calendar1").Visible = False
    
End Sub

Open in new window


Also, see attached file.

Enjoy!

Dave
CalendarVisible-r1.xlsm
0
 

Author Closing Comment

by:AndresHernando
ID: 34993716
Ah...  I needed to reference the worksheet where the object resides.

Thanks!!!!   --Andres
0
 
LVL 41

Expert Comment

by:dlmille
ID: 34993723
Andres, when in doubt, turn on your macro recorder and then change properties of a shape (e.g., Visible to true/false) and the recorder will show you the way!

Dave
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now