filepath - VBA erroneously adds slashes to formatted date -


a file created every friday formatting: "report 08 11 2017.xlsx"

dim iweekday integer, lastfridaydate date iweekday = weekday(now(), vbfriday)  lastfridaydate = format(now - (iweekday - 1), "mm dd yyyy") 

lastfridaydate formatted way appears in file path, '08 11 2017'. however, when attempt open workbook via:

dim lw_report workbook  set lw_report= workbooks.open("report " & lastfridaydate & ".xlsx") 

i error: "report 08\22\2017.xlsx" cannot found

how can file path created spaces preserved?

lastfridaydate defined date when trying open workbook date concatenated standard date formatting.

to fix dim lastfridaydate string

dim iweekday integer, lastfridaydate string iweekday = weekday(now(), vbfriday)  lastfridaydate = format(now - (iweekday - 1), "mm dd yyyy") dim lw_report workbook  set lw_report = workbooks.open("report " & lastfridaydate & ".xlsx") 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -