Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro who can help me?

Status
Not open for further replies.

jvaneert

MIS
Sep 10, 2002
18
0
0
NL
Hello there,

I am trying to save an impromptu report (Report A) on a daily basis as a hotfile.
I want 5 hotfiles per week, e.g. for each working day.
So Hotfile Monday, Hotfile Tuesday, Hotfile Wednesday, Hotfile Thursday, Hotfile Friday.

I the week is over and it is mondat then the Hotfile Monday needs to be overwritten by the new report.

How can i schedule this? Should i Use a macro? But i am not familiar with macro's can someone please give me a macro?

Thanks a lot.

Jules
 
Jules,
Use a macro, it's easier. Weekday function returns a number 1-7 (or 0-6) according to day of the week and the Format function converts it to a weekday name.
Something like this ought to do it - adjust as required
Code:
Sub Main()
   'variables
   Dim strfilename as string
   'objects
   Dim objImpApp As object
   Dim objImpRep As Object 
   '
   'Open Impromptu and get revaluation of stock
   Set objImpApp = CreateObject("CognosImpromptu.Application")
   objImpApp.Visible 1
   objImpApp.OpenCatalog "D:\catalogues\JulesCat.cat","Creator",,,,1

   Set objImpRep = objImpApp.OpenReport ("D:\reports\Jules Report.imr")
    Set objImpRep = objImpApp.ActiveDocument
    'save data as hotfile with day of the month as part of name
    strfilename = "D:\hotfile " & Format(weekday(Cvar(DATE)), "dddd") & ".ims"
   objImpRep.ExportHotFile strfilename
   objImpRep.CloseReport

   objImpApp.Quit
   Set objImpApp = Nothing
   Set objImpRep = Nothing
   
Exit Sub

soi la, soi carré
 
Hi Dr Lex
Thanks for your macro, i have adjusted it to my report and catalog name but when i run the macro it says : "MAC(25) Error: Unexpected end of file"
What am i doing wrong
Regards,
Jules
 
Jules,
apologies - the last line should be 'End Sub' and not 'Exit Sub'
mea culpa
lex

soi la, soi carré
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top