Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to save excel file with current date using macro

Hi all,

I have a sheet with 2 objects.

These objects are sent to an existing Excel document using macro. (Found on this community)

Then is saves the file (overwrite)

I need to save the file with a sort of timestamp in it's document name.

Who can help me?

I need to save the file like this:

   ' Save and quit 

   objExcelSheet.SaveAs "C:\documenten\test\test20140612.xlsx"

   objExcelApp.Application.Quit 

   SET objExcelSheet = NOTHING       

   SET objExcelApp = NOTHING 

But then with a variable date / date function.

Thanks,

Kevin

1 Solution

Accepted Solutions
Not applicable
Author



  1. ' Save and quit   
  2.    vX=Year(now())&month(now())&day(now())
  3.    objExcelSheet.SaveAs "C:\documenten\test\test"&vX&".xlsx" 
  4.    objExcelApp.Application.Quit   
  5.    SET objExcelSheet = NOTHING         
  6.    SET objExcelApp = NOTHING

  7. Hope this helps

View solution in original post

4 Replies
Not applicable
Author



  1. ' Save and quit   
  2.    vX=Year(now())&month(now())&day(now())
  3.    objExcelSheet.SaveAs "C:\documenten\test\test"&vX&".xlsx" 
  4.    objExcelApp.Application.Quit   
  5.    SET objExcelSheet = NOTHING         
  6.    SET objExcelApp = NOTHING

  7. Hope this helps
Not applicable
Author

Thank you,

This was the right solution..

Now I have 1 more question:

I want Qlikview to open the saved file

This is an action on a button that calls the Macro and opens the file.

I need the same date in this screen at "bestandsnaam": (Sorry for the dutch system language)

save excel file.jpg

Someone who knows how to solve this?

Thanks,

Kevin

Not applicable
Author

place this expression in place of filename/bestandsnaam.

='D:\Test\Test'& year(today())&num(Month(Today()),00)&day(today())&'.xlsx'

or

='D:\Test\Test'& year(today())&Repeat('0', 2 - Len(num(Month(Today()))) )& num(Month(Today()))&day(today())&'.xlsx'

Not applicable
Author

Thanks!

This works