Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Excel VBA - How to Control Calendar Object from Module

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to line 23 53
how to do this Excel search box Soundex Search 6 27
enable formatting rows through Thsworkbook VBA code 5 13
vba to flip column 14 18
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

839 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