I am new to the forum but an active searcher and reader of this site for coding solutions.
I am enclosing some code that is part of a task i have scheduled which will open a file, refresh the data (line removed), and save it with a time stamp.
Option Explicit
Dim Xlapp, Xlbook,wbnam,ext,dt
Set Xlapp = CreateObject("Excel.Application")
xlapp.visible = TRUE
Set XlBook = xlapp.Workbooks.Open("C:\Users\newtonm\Box Sync\Matthew.Newton\Campaign Deliverables\Donor Dev\Weekly 10k\WklyTest.xlsx")
wbnam = "C:\Users\newtonm\Box Sync\Matthew.Newton\Campaign Deliverables\Donor Dev\weekly 10k\wklytest"
dt = format(date,"yyyy_mm_dd")
ext = ".xlsx"
xlbook.SavecopyAs wbnam&dt&ext
xlbook.Close false
xlapp.quit
set xlbook = Nothing
set xlapp = Nothing
When I execute the code - I am getting the following error.
I am presuming that 1 of 2 things is going on 1) The syntax of the Format Function is awry or. 2) Creating the Dim for DT is missing something.
Any help for this would be quitre helpful as i have been spinning my wheels for a bit on this.