Solved

Excel VBA - How to Control Calendar Object from Module

Posted on 2011-02-25
5
364 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

706 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

21 Experts available now in Live!

Get 1:1 Help Now