Close Workbook after it was opened by task scheduler

ac3100

Board Regular
Joined
Aug 21, 2002
Messages
185
I have a workbook that I open with the task scheduler.

I don't want to use any code to close itself.

So that means that I want to save and close it using another workbook.

How can I aceive this?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I'm not too sure what you mean that not wanting to use any code to close itself.

Why don't you just delete the
Workbook.Close command from the workbook code?
 
Upvote 0
I guess that wasn't too clear.

The workbook that gets opened by the task scheduler performs a data refresh.

After the first workbook is opened, I want to open a second workbook to save and close it.
 
Upvote 0
This appears to work:
Dim WB As Workbook

For Each WB In Workbooks
If WB.Name = "Account Advanced Find View.xlsx" Then WB.Close SaveChanges:=True
Next

Under a different method I was getting a subscript out of range error.
 
Upvote 0
Actually that did not work because the second file opens up a separate instance of Excel. This is very frustrating!
 
Upvote 0

Forum statistics

Threads
1,224,531
Messages
6,179,379
Members
452,907
Latest member
Roland Deschain

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