I have recorded a "save as" macro but I need the macro to save the date and time in the file name, I keep getting a sintax error. Can anyone help please?

System used id windows 7 and 8

Of course - you have to correct the syntax-Error

Sorry - nobody can really help without reading the grumpy Makrocode

Thanks for pointing out my spelling, it had been a long day.
I have copied the coding but I cant get the SYNTAX right, to be able to save each time with a date and time within the file name. Could some one look at the code and work out how to get it to add “NOW” to the file name "PLANT%20CHECKv1.2.4.odt

sub P_DRIVE_SAVE_AS
    dim document   as object
    dim dispatcher as object
    document   = ThisComponent.CurrentController.Frame
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

    dim args1(1) as new com.sun.star.beans.PropertyValue
    args1(0).Name = "URL"
    args1(0).Value = "file:///P:/Engineering/Plant%20Check%20Results/PLANT%20CHECKv1.2.4.&"NOW"().odt"
    args1(1).Name = "FilterName"
    args1(1).Value = "writer8"

    dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args1())


end sub 

[edit code for readability Karolus ]

I think the error is the dispatcher.executeDispatch(document, “.uno:SaveAs”, “”, 0, args1())

Thanks
Phil

Should work if you change args1(0).value = .... to

args1(0).Value = "file:///P:/Engineering/Plant%20Check%20Results/PLANT%20CHECKv1.2.4." & NOW & "().odt"

Hi

Warn to the creation of subfolders, if the NOW function returns the date as: 15/05/2015 17:28:47 (my environment is french).

You can avoid it by removing your separator (e.g. / and :) this way:

dim sUrl as string
args1(0).Name = "URL"
sUrl =  "file:///C:/Engineering/Plant%20Check%20Results/PLANT%20CHECKv1.2.4." 
sUrl =  sUrl & join(split(join(split(now, "/"), ""), ":")) & ".odt" 
args1(0).Value = sUrl

Regards

@PYS

format(now, "yyyy-mm-dd--hh:mm") 'or simlar'

Of course… Why complicate life to make it simple when it’s so simple to complicate, again… Thank’s @Karolus :slight_smile: