Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jk jk is offline
external usenet poster
 
Posts: 109
Default Macro change on rename

I am using a macro to place a timestamp on workbook open and it saves it at
this time but if i rename the work book, then try to run the macro i receive
a file not found.

Private Sub Workbook_Open()
Worksheets("Sheet4").Range("I1").Value = Format(Now, "dd mmm yyyy
hh:mm:ss")
End Sub
Sub DateTime()

Worksheets("Sheet4").Range("I1").Value = _
Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
The above code is what i am using and it works but the renaming of the file
could be an issue.Is there a work around on this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Macro change on rename

There's nothing in the code to indicate the filename at all.
Or do you mean renaming the worksheet ?

NickHK
P.S. Is this a .CSV file or a true Excel .xls file ?

"jk" wrote in message
...
I am using a macro to place a timestamp on workbook open and it saves it

at
this time but if i rename the work book, then try to run the macro i

receive
a file not found.

Private Sub Workbook_Open()
Worksheets("Sheet4").Range("I1").Value = Format(Now, "dd mmm yyyy
hh:mm:ss")
End Sub
Sub DateTime()

Worksheets("Sheet4").Range("I1").Value = _
Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
The above code is what i am using and it works but the renaming of the

file
could be an issue.Is there a work around on this?



  #3   Report Post  
Posted to microsoft.public.excel.programming
jk jk is offline
external usenet poster
 
Posts: 109
Default Macro change on rename

This is an excel file and i have code to work on workbook open and also for
the time and that is placed in a module of the workbook. I created a custom
button to activate the macro to current time then save and it works fine.The
problem is if i want to rename the workbook then try to run the macro, it
does not recognize the file.

"NickHK" wrote:

There's nothing in the code to indicate the filename at all.
Or do you mean renaming the worksheet ?

NickHK
P.S. Is this a .CSV file or a true Excel .xls file ?

"jk" wrote in message
...
I am using a macro to place a timestamp on workbook open and it saves it

at
this time but if i rename the work book, then try to run the macro i

receive
a file not found.

Private Sub Workbook_Open()
Worksheets("Sheet4").Range("I1").Value = Format(Now, "dd mmm yyyy
hh:mm:ss")
End Sub
Sub DateTime()

Worksheets("Sheet4").Range("I1").Value = _
Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
The above code is what i am using and it works but the renaming of the

file
could be an issue.Is there a work around on this?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Macro change on rename

So, it has nothing to do with the code you posted, but to with the location
from which you are calling this code ?
Where is the calling button/code located ?

If in Personal.xls, why not change the routine to insert the formatted
date/time in the current cell. Then it will work for any WB/WS you have open
and the filename will not matter :
Sub InsertDateTime()
ActiveCell.Value = Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub

You should add error handling in case the above is invalid.

Or depending how you are creating the button, you can specify the workbook
with ThisWorkbook.Name .

NickHK

"jk" wrote in message
...
This is an excel file and i have code to work on workbook open and also

for
the time and that is placed in a module of the workbook. I created a

custom
button to activate the macro to current time then save and it works

fine.The
problem is if i want to rename the workbook then try to run the macro, it
does not recognize the file.

"NickHK" wrote:

There's nothing in the code to indicate the filename at all.
Or do you mean renaming the worksheet ?

NickHK
P.S. Is this a .CSV file or a true Excel .xls file ?

"jk" wrote in message
...
I am using a macro to place a timestamp on workbook open and it saves

it
at
this time but if i rename the work book, then try to run the macro i

receive
a file not found.

Private Sub Workbook_Open()
Worksheets("Sheet4").Range("I1").Value = Format(Now, "dd mmm yyyy
hh:mm:ss")
End Sub
Sub DateTime()

Worksheets("Sheet4").Range("I1").Value = _
Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
The above code is what i am using and it works but the renaming of the

file
could be an issue.Is there a work around on this?






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Macro change on rename

I am as confused as Nick on this, the code you mention above simply
changes a timedate stamp on Sheet 4.

You are try to save this workbook as another name, and then when you
open the copied workbook the macro won't run?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,886
Default Macro change on rename

Hi

Answered in your original thread in excel.misc

--
Regards

Roger Govier


"jk" wrote in message
...
This is an excel file and i have code to work on workbook open and
also for
the time and that is placed in a module of the workbook. I created a
custom
button to activate the macro to current time then save and it works
fine.The
problem is if i want to rename the workbook then try to run the macro,
it
does not recognize the file.

"NickHK" wrote:

There's nothing in the code to indicate the filename at all.
Or do you mean renaming the worksheet ?

NickHK
P.S. Is this a .CSV file or a true Excel .xls file ?

"jk" wrote in message
...
I am using a macro to place a timestamp on workbook open and it
saves it

at
this time but if i rename the work book, then try to run the macro
i

receive
a file not found.

Private Sub Workbook_Open()
Worksheets("Sheet4").Range("I1").Value = Format(Now, "dd mmm
yyyy
hh:mm:ss")
End Sub
Sub DateTime()

Worksheets("Sheet4").Range("I1").Value = _
Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
The above code is what i am using and it works but the renaming of
the

file
could be an issue.Is there a work around on this?






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rename name so formulas show name change John New Users to Excel 3 November 4th 06 03:45 AM
Macro to rename .doc InventoryQueryGuy Excel Programming 3 August 10th 06 04:25 PM
Change/Rename List Django Excel Discussion (Misc queries) 0 June 27th 06 07:33 PM
Rename Macro rmpete Excel Discussion (Misc queries) 3 February 11th 06 10:24 PM
rename macro Lois Excel Programming 1 October 13th 04 06:04 PM


All times are GMT +1. The time now is 08:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"