unable to activate and close the appended filename with the date

pals70423

New Member
Joined
Feb 6, 2011
Messages
25
Hi All,
i am writing a macro to activate a opened file and close the file.the files are generated on daily basis with date appended to it.i combining the string along with the date to activate and close the excel but i am unable to achive this.kindly help

code:

dim daily_timestamp as string
dim daily_filename as string
daily_timestamp = InputBox("Enter the date in YYYY-MM-DD format")
daily_filename = test
Windows("C:\pals\macros\test\"test_" & daily_timestamp & ".xls").Activate
Application.CutCopyMode = False
ActiveWindow.Close
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Think you have a syntax error; you only have 5 speach marks and I think you need either 4 or 6
Rich (BB code):
Windows("C:\pals\macros\test\"test_" & daily_timestamp & ".xls").Activate
Maybe it should be:
Rich (BB code):
Windows("C:\pals\macros\test\test_" & daily_timestamp & ".xls").Activate
Or
Rich (BB code):
Windows("C:\pals\macros\" & daily_filename & "\test_" & daily_timestamp & ".xls").Activate
 
Upvote 0
Hi,
I have changed the code but still getting the same error

Windows("C:\pals\macros\test\test_" & daily_timestamp & ".xls").Activate

run time error 9

sub script out of range
 
Upvote 0
I don't think you need the path part of the string.
Try:
Code:
Windows(test_" & daily_timestamp & ".xls").Activate
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,735
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top