H
Hari
Hi,
I have a workbook by the name -- " ABC.xls"
It could be possible that it is not activated.
I want to save this workbook by appending todays' date to the present name.
I wrote the code ( Pinched it from NG) :-
Windows("ABC.xls").Activate
If InStr(ActiveWorkbook.Name, CStr(Format(Now, "dd-mmm-yy"))) = 0 Then
ActiveWorkbook.SaveAs filename:= _
"C:\Documents and Settings\hprasadh\Desktop\xyz\Project comparison\ABC
" & " " & CStr(Format(Now, "dd-mmm-yy")), FileFormat:=xlNormal
End If
The above is part of a bigger code and my code gets a compile error at the
point Windows("ABC.xls").Activate . I tried changing it to
Windows("ABC").Activate but to no avail.
Curiously at other points of the code also when I try to activate this sheet
using this line ( in order to perform some cut paste operation) it bombs at
the same point.
1. Please tell me why this is happening.
2. Is there a way I can save the "ABC.xls" as a new workbook with the
filename "C:\Documents and Settings\hprasadh\Desktop\xyz\Project
comparison\ABC " & " " & CStr(Format(Now, "dd-mmm-yy")),
FileFormat:=xlNormal. Why Im asking this is presently while saving
ActiveWorkbook.SaveAs filename statement has to be used and if there is a
way one could save a POSSIBLY unactivated sheet without first activating it
my problem may be solved. ( Still please do tell me at the firs place why is
the activate code not working)
{ The file does have the name "ABC" only. I copied the filename from
rightclick properties to doublecheck }
Regards,
Hari
India
I have a workbook by the name -- " ABC.xls"
It could be possible that it is not activated.
I want to save this workbook by appending todays' date to the present name.
I wrote the code ( Pinched it from NG) :-
Windows("ABC.xls").Activate
If InStr(ActiveWorkbook.Name, CStr(Format(Now, "dd-mmm-yy"))) = 0 Then
ActiveWorkbook.SaveAs filename:= _
"C:\Documents and Settings\hprasadh\Desktop\xyz\Project comparison\ABC
" & " " & CStr(Format(Now, "dd-mmm-yy")), FileFormat:=xlNormal
End If
The above is part of a bigger code and my code gets a compile error at the
point Windows("ABC.xls").Activate . I tried changing it to
Windows("ABC").Activate but to no avail.
Curiously at other points of the code also when I try to activate this sheet
using this line ( in order to perform some cut paste operation) it bombs at
the same point.
1. Please tell me why this is happening.
2. Is there a way I can save the "ABC.xls" as a new workbook with the
filename "C:\Documents and Settings\hprasadh\Desktop\xyz\Project
comparison\ABC " & " " & CStr(Format(Now, "dd-mmm-yy")),
FileFormat:=xlNormal. Why Im asking this is presently while saving
ActiveWorkbook.SaveAs filename statement has to be used and if there is a
way one could save a POSSIBLY unactivated sheet without first activating it
my problem may be solved. ( Still please do tell me at the firs place why is
the activate code not working)
{ The file does have the name "ABC" only. I copied the filename from
rightclick properties to doublecheck }
Regards,
Hari
India