Save as unique file name but then I need Activate that file name

s_woodbury

New Member
Joined
Feb 26, 2014
Messages
27
I have a script that makes the user choice which xls file to use. The script saves the file with a unique name by using todays date.

That works, it's when I try to use Windows(xxxxxxxxxxx).Activate that I have problems.

Here's how I save the file.

ActiveWorkbook.SaveAs Filename:= _
"C:\Users\swoodbury\Documents\Old HR LO List-" _
& Format$(Date, "MMDDYYYY") _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

What can I use to activate that window? I tried:

Windows("New HR LO List-" & Format$(Date, "MMDDYYY") & ".xls").Activate

Any advice is appreciated! Thanks - Scott
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi Scott,

After Workbook.SaveAs, the new workbook should be the ActiveWorkbook (with a new name). Is that not the case for you?

You should be able to refer to the new workbook in one of these ways....

Code:
 ActiveWorkbook.SaveAs Filename:= _
     "C:\Users\swoodbury\Documents\Old HR LO List-" _
     & Format$(Date, "MMDDYYYY") _
     , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

'--reference the activeworkbook...
 Msgbox "New Name is: " & ActiveWorkbook.Name

'---or assign the new workbook object to a variable
 Dim wkbNew as Workbook
 Set wkbNew = ActiveWorkbook
 Msgbox "New Name is: " & wkbNew.Name
 
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,930
Members
449,195
Latest member
Stevenciu

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