Code works / code doesnt work

  • Hi there,


    I am running excel 2003 and i tried to run this code on excel 97 and it would not work. Does anyone know why? The compiler highlights Range and Replace.


    Any ideas???


    ActiveSheet.copy
    ActiveWorkbook.SaveAs Filename:="C:\sch\" & Range("b10") & "_" & Range("b11") & "_" & Replace(Date, "/", "-") & "_" & Replace(Format(Time, "HH:MM AM/PM"), ":", "-") & ".xls", FileFormat:=xlNormal, _
    Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
    CreateBackup:=False
    sendtoapprover.Show

  • I have a feeling that Replace might not be available in 97.


    Richie will know as he still uses it at work... I'm now 2000+


    (Have a look in the 97 help under replace & see if it lists it)

  • Hi willr,


    I thought as much with replace but what is really strange is the use of range not working!


    oh well i will think of something!


    thanks


    steve

  • Hi Steve,


    I think the highlighting of Range is a red herring. It's definitely the Replace() causing problems. If you add your own function Replace() in xl97 it compiles ok.


    In your case I think you can use the Format function to do the work.
    I tried this two variations in the immediate window in xl97

    Code
    ?Format(Time, "HH-MM AM/PM"),Format(Time, "HH:MM AM/PM")
    10-48 AM      10:48 AM

    [h4]Cheers
    Andy
    [/h4]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!