Can an object be named with the time or date + time

teamsimpson

New Member
Joined
Sep 20, 2002
Messages
22
Does anyone know any code (or if it can be done) that will let me use the .Name = "get time off clock" to name the object.That way if my code is run several times, the objects are named as a time, so each name will be different so i won't have to write code that has to check the name before it renames the object.
Regards
Mike
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Even if this were possible I am not sure that it would serve your purpose. What is your code doing? Post a snippet.
 
Upvote 0
Sub Macro2()

' Keyboard Shortcut: Ctrl+q


Sheets("TEST").OLEObjects.Add(FileName:="h:data.xls", Link:=False).Name = "new"

With Sheets("TEST").OLEObjects("new")
.Left = 200
.Top = 200
.Width = 40
.Height = 25

ActiveSheet.Shapes("new").Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 40
ActiveSheet.Shapes("new").Name = "data 1"

End With
Sheets("TEST").[a1].Activate
End Sub
 
Upvote 0
The best way to keep track of your shape is to assign it to an Object variable when you add it. Like this:

Code:
Sub Test()
    Dim MyShape As OLEObject
    Set MyShape = Sheets("TEST").OLEObjects.Add(Filename:="h:data.xls", Link:=False)
    With MyShape
        .Left = 200
        .Top = 200
        .Width = 40
        .Height = 25
        .ShapeRange.Fill.ForeColor.SchemeColor = 40
        .Name = "data 1"
    End With
    Sheets("TEST").[a1].Activate
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,393
Messages
6,119,261
Members
448,880
Latest member
aveternik

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top