+ Reply to Thread
Results 1 to 3 of 3

Adding Current month and year to VBA generated text box

  1. #1
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Pune
    MS-Off Ver
    Office 365 (Win 10)
    Posts
    489

    Adding Current month and year to VBA generated text box

    Hi,
    I got this code for another site.
    Can you please help me to put the code to add the current month and year also in the text box which is getting added to excel by the below code?

    PHP Code: 
    Sub add_textbox_VBA() 

    Dim shp As Shape
     Set shp 
    ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal10010020050' add shape
     With shp
     .TextFrame.Characters.Text = "Uncontrolled. Valide only for MMM-YY" ' 
    add text to display
     
    .Top Range("e2").Top ' adjust top
     .Left = Range("e2").Left '
    adjust left
     
    .TextFrame.AutoSize True ' turn on autosize
     .Fill.ForeColor.RGB = RGB(255, 255, 204) '
    choose fill color
     
    .Line.Weight ' adjust width
     .Line.ForeColor.RGB = RGB(255, 0, 18) ' 
    choose color
     
    .Line.DashStyle msoLineSolid ' choose style
     End With 

    End Sub 
    In this MMM-YY should be coming as the current month and year


    Thanks in advance
    Please make the Post as solved, when you get your answer & Click * if you like my suggestion

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Adding Current month and year to VBA generated text box

    Hi, akhileshgs,

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Pune
    MS-Off Ver
    Office 365 (Win 10)
    Posts
    489

    Re: Adding Current month and year to VBA generated text box

    Works like a charm..

    thank you very much...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 03-14-2014, 08:47 PM
  2. Change year but keep the month the same based on current year
    By Jamon Fries in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-11-2014, 05:29 PM
  3. Replies: 3
    Last Post: 09-04-2013, 10:49 AM
  4. Current Year & Month Name, Previous Year & Month Name
    By mithesh in forum Excel General
    Replies: 9
    Last Post: 10-21-2011, 07:00 AM
  5. [SOLVED] Auto insert current month's name and current year
    By Webtekr in forum Word Formatting & General
    Replies: 0
    Last Post: 03-03-2009, 05:20 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1