Kamis, 03 Mei 2012

[ExcelVBA] Re: LastRunDate - Where is this property stored

 

I found a way to see that date on the internet. Basically, it will put the information into a couple cells on one of the worksheets when you do it this way. This code does work, because I played around with the computer calendar by moving it back a few months and saving, then reopened again in the same month and nothing happened. However, when I bumped it up to the next month, those cells would show that the code ran.

Private Sub Workbook_Open()
Dim bError As Boolean
Dim iLastMonth As Integer
Dim datLastRun As Date

On Error Resume Next
datLastRun = ThisWorkbook.CustomDocumentProperties.Item("LastRunDate")
bError = Err.Number <> 0
On Error GoTo 0

If bError = False Then iLastMonth = Month(datLastRun)

If iLastMonth <> Month(Date) Then

'MsgBox "run your macro here"
ssRMAAddNextMonthsFormulas.RMAFindLastNonEmptyCellInRowRangeCopyFormulasOverFromColToLeft

Cells(2, 1).Value = Format(Now, "hh:mm ampm")
Cells(1, 1).Value = Format(Now, "mm/dd/yyyy")

With ThisWorkbook.CustomDocumentProperties
If bError Then
.Add Name:="LastRunDate", _
LinkToContent:=False, _
Type:=msoPropertyTypeDate, _
Value:=Date
Else
.Item("LastRunDate").Value = Date
End If
End With
End If

End Sub

--- In ExcelVBA@yahoogroups.com, "David Smart" <smartware.consulting@...> wrote:
>
> I'm not aware of this property. Could you post the code or a link to it.
>
> Regards, Dave S
>
> ----- Original Message -----
> From: "sspatriots" <sspatriots@...>
> To: <ExcelVBA@yahoogroups.com>
> Sent: Thursday, May 03, 2012 9:56 AM
> Subject: [ExcelVBA] LastRunDate - Where is this property stored
>
>
> > Today I ran across code that used the 'LastRunDate' and read that it was
> > stored in some property in the workbook. Is there a way I can I see what
> > that date is?
> >
> >
> > Thanks,
> >
> > Steve
> >
> >
> >
> > ------------------------------------
> >
> > ----------------------------------
> > Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go
> > here: http://www.mousetrax.com/techtrax to enter the ezine, then search
> > the ARCHIVES for EXCEL VBA.
> >
> > ----------------------------------
> > Visit our ExcelVBA group home page for more info and support files:
> > http://groups.yahoo.com/group/ExcelVBA
> >
> > ----------------------------------
> > More free tutorials and resources available at:
> > http://www.mousetrax.com
> >
> > ----------------------------------Yahoo! Groups Links
> >
> >
> >
> >
> >
> > -----
> > No virus found in this message.
> > Checked by AVG - www.avg.com
> > Version: 10.0.1424 / Virus Database: 2411/4973 - Release Date: 05/02/12
> >
>

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar