Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Trouble setting variable as filename with date
Hi,
I'm trying to set a variable as a filename, and keep getting a compile error "Object required." - it selects my variable "Newfilename =" when this happens Here's a snip: Sub Namefile() Const Dirpath As String = "C:\WINNT\Profiles\elby\Desktop\" Dim newfilename As String Set newfilename = Dirpath & format((Date - 1), "mmm-dd-yy") & "_Pres" & ".xls" End sub I'm working in VBA - Excel 97, new at this. Any ideas much appreciated! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Trouble setting variable as filename with date
Object variables require the Set statement. Regular variables can use
the optional Let statement (but almost nobody does). Instead: Public Sub Namefile() Const Dirpath As String = "C:\WINNT\Profiles\elby\Desktop\" Dim newfilename As String newfilename = Dirpath & Format((Date - 1), "mmm-dd-yy") & _ "_Pres.xls" End Sub In article , (Elby) wrote: Hi, I'm trying to set a variable as a filename, and keep getting a compile error "Object required." - it selects my variable "Newfilename =" when this happens Here's a snip: Sub Namefile() Const Dirpath As String = "C:\WINNT\Profiles\elby\Desktop\" Dim newfilename As String Set newfilename = Dirpath & format((Date - 1), "mmm-dd-yy") & "_Pres" & ".xls" End sub I'm working in VBA - Excel 97, new at this. Any ideas much appreciated! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Trouble setting variable as filename with date
So simple, yet so much time I wasted trying to get that right! Thanks a
bunch - that's twice today you've helped me out (I also grabbed your code from "Invalid use of null" - I've been trying to trim a range, and this works!) *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
trouble setting colors | Charts and Charting in Excel | |||
set filename to <filename-date on open | Excel Worksheet Functions | |||
Put Filename Variable in Macro | Excel Discussion (Misc queries) | |||
Global Setting For All Workbooks - Filename In Footer | Excel Worksheet Functions | |||
Trouble setting total for on chart | Charts and Charting in Excel |