Close almost all workbooks

C

ChrisP

I've written some VBA code to open one workbook (call it "A") and in the open
event for workbook A I have it coded to open various other workbooks ("B",
"C", "D", etc).

I'm doing it this way so all the links are updated (one is password
protected and I can't give out the password so I've had to code opening them
in VBA and lock the VBA code).

I have everything I need except how to close workbooks B, C, D, etc. I don't
want to close all the workbooks as users may have other excel workbooks open
at the time. Any help is appreciated!

Thanks,
Chris
 
P

Per Jessen

Hi Chris

Look at this:

Set wbB = Workbooks.Open(Filename:="Book1.xls") ' Open "B"
'Your code
'More code
wbB.Close ' Close "B"

Hopes it helps

Best regards,
Per
 
C

ChrisP

Thanks! One more question, workbooks B & C I don't want to save but D I do.
How would I write that?

Thanks again!
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top