Solved

Excel VBA - How to Control Calendar Object from Module

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

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 42

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

680 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