PC Review


Reply
Thread Tools Rate Thread

Add footer automatically

 
 
bgelbord@gmail.com
Guest
Posts: n/a
 
      4th Dec 2006
Let me start by saying that I am new to programming VBA Macros, but I'm
learning on the fly and I'll be happy to try out any and all
suggestions. Now, on to the problem.

We're trying to come up with a way of having a unique id number for
every new document created. I think that a good way to do this is to
create templates for word and excel (the two programs we use for
document creation). I'm trying to come up with a macro for the
templates that automatically adds a footer with a trimmed down
time/date stamp upon the first save. By "trimmed down" I mean that
12/04/2006 11:15:32PM would be shortened to 12042006111532. I only
need it to do this the first time a document is saved because if the
time/date updated itself every time the document was used it would
undermine the whole plan for unique document id numbers.

Thanks for your help.
Brett

 
Reply With Quote
 
 
 
 
Nick Hodge
Guest
Posts: n/a
 
      4th Dec 2006
Brett

If you only have a single worksheet in the template, (mine uses sheet1),
save this workbook_open code in the ThisWorkbook module

Private Sub Workbook_Open()
Dim yy As String
Dim mnth As String
Dim dd As String
Dim hh As String
Dim mm As String
Dim ss As String
Dim FooterString As String
yy = Year(Date)
mnth = Format(Month(Date), "00")
dd = Format(Day(Date), "00")
hh = Format(Hour(Time), "00")
mm = Format(Minute(Time), "00")
ss = Format(Second(Time), "00")
FooterString = mnth & dd & yy & hh & mm & ss
Worksheets("Sheet1").PageSetup.RightFooter = FooterString
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(E-Mail Removed)DTHIS
www.nickhodge.co.uk


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Let me start by saying that I am new to programming VBA Macros, but I'm
> learning on the fly and I'll be happy to try out any and all
> suggestions. Now, on to the problem.
>
> We're trying to come up with a way of having a unique id number for
> every new document created. I think that a good way to do this is to
> create templates for word and excel (the two programs we use for
> document creation). I'm trying to come up with a macro for the
> templates that automatically adds a footer with a trimmed down
> time/date stamp upon the first save. By "trimmed down" I mean that
> 12/04/2006 11:15:32PM would be shortened to 12042006111532. I only
> need it to do this the first time a document is saved because if the
> time/date updated itself every time the document was used it would
> undermine the whole plan for unique document id numbers.
>
> Thanks for your help.
> Brett
>


 
Reply With Quote
 
Jezebel
Guest
Posts: n/a
 
      4th Dec 2006
You don't need any VBA to do that. Just a field:

{ createdate \@ "yyyyMMddHHmmss" }


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Let me start by saying that I am new to programming VBA Macros, but I'm
> learning on the fly and I'll be happy to try out any and all
> suggestions. Now, on to the problem.
>
> We're trying to come up with a way of having a unique id number for
> every new document created. I think that a good way to do this is to
> create templates for word and excel (the two programs we use for
> document creation). I'm trying to come up with a macro for the
> templates that automatically adds a footer with a trimmed down
> time/date stamp upon the first save. By "trimmed down" I mean that
> 12/04/2006 11:15:32PM would be shortened to 12042006111532. I only
> need it to do this the first time a document is saved because if the
> time/date updated itself every time the document was used it would
> undermine the whole plan for unique document id numbers.
>
> Thanks for your help.
> Brett
>



 
Reply With Quote
 
B.
Guest
Posts: n/a
 
      4th Dec 2006
Thank you Nick. I tried this out, and the only problem is that I don't
know how to get it to stop updating the time and date every time the
doc is opened and saved. I don't know if that's even possible.

Nick Hodge wrote:
> Brett
>
> If you only have a single worksheet in the template, (mine uses sheet1),
> save this workbook_open code in the ThisWorkbook module
>
> Private Sub Workbook_Open()
> Dim yy As String
> Dim mnth As String
> Dim dd As String
> Dim hh As String
> Dim mm As String
> Dim ss As String
> Dim FooterString As String
> yy = Year(Date)
> mnth = Format(Month(Date), "00")
> dd = Format(Day(Date), "00")
> hh = Format(Hour(Time), "00")
> mm = Format(Minute(Time), "00")
> ss = Format(Second(Time), "00")
> FooterString = mnth & dd & yy & hh & mm & ss
> Worksheets("Sheet1").PageSetup.RightFooter = FooterString
> End Sub
>
> --
> HTH
> Nick Hodge
> Microsoft MVP - Excel
> Southampton, England
> (E-Mail Removed)DTHIS
> www.nickhodge.co.uk
>
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Let me start by saying that I am new to programming VBA Macros, but I'm
> > learning on the fly and I'll be happy to try out any and all
> > suggestions. Now, on to the problem.
> >
> > We're trying to come up with a way of having a unique id number for
> > every new document created. I think that a good way to do this is to
> > create templates for word and excel (the two programs we use for
> > document creation). I'm trying to come up with a macro for the
> > templates that automatically adds a footer with a trimmed down
> > time/date stamp upon the first save. By "trimmed down" I mean that
> > 12/04/2006 11:15:32PM would be shortened to 12042006111532. I only
> > need it to do this the first time a document is saved because if the
> > time/date updated itself every time the document was used it would
> > undermine the whole plan for unique document id numbers.
> >
> > Thanks for your help.
> > Brett
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set Header and footer automatically Carpe Diem Microsoft Excel Programming 5 28th Mar 2007 01:07 AM
How to ALWAYS have footer automatically? =?Utf-8?B?RG9ubmE=?= Microsoft Excel Worksheet Functions 2 2nd Nov 2006 11:10 PM
automatically insert footer jimmyp Microsoft Excel Misc 3 15th May 2006 01:37 PM
How to set a default footer that automatically comes up on new do. =?Utf-8?B?Um9va2ll?= Microsoft Word Document Management 1 11th Feb 2005 05:42 PM
File name in footer automatically nospam Microsoft Powerpoint 9 8th May 2004 04:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:45 PM.