Macro: Closing files without saving

S

Snoopy

Hey guys
I'm trying to pull together data from several workbooks.
To do this I have to modify every submitting workbook (show hidden
columns etc). There are apx 100 subsequent submitting files to open,
processing and close
In the macro I open the files as "read only" to prevent unwanted
actions.

My problem is that a message "Will you save this file" appears at
the
ActiveWorkbook.Close macro VBA statement when the file is to close
after ended action.
Of course I can push the "no" button every singel time - but I expect
the must be a way to make my macro close the file without saving it
and without messaging.

All the rest of my macro seems to work well.

Will any one "out there" please give me some exact advice to eliminate
this problem?

Best regards
Snoopy
 
D

Dave Peterson

try:

ActiveWorkbook.Close savechanges:=false


Hey guys
I'm trying to pull together data from several workbooks.
To do this I have to modify every submitting workbook (show hidden
columns etc). There are apx 100 subsequent submitting files to open,
processing and close
In the macro I open the files as "read only" to prevent unwanted
actions.

My problem is that a message "Will you save this file" appears at
the
ActiveWorkbook.Close macro VBA statement when the file is to close
after ended action.
Of course I can push the "no" button every singel time - but I expect
the must be a way to make my macro close the file without saving it
and without messaging.

All the rest of my macro seems to work well.

Will any one "out there" please give me some exact advice to eliminate
this problem?

Best regards
Snoopy
 
P

Pete_UK

Try putting this line before you close the file:

Application.DisplayAlerts = False

and this one after:

Application.DisplayAlerts = True

Hope this helps.

Pete
 
S

Snoopy

Try putting this line before you close the file:

    Application.DisplayAlerts = False

and this one after:

    Application.DisplayAlerts = True

Hope this helps.

Pete







– Vis sitert tekst –

Thanks a lot :)
 
S

Snoopy

try:

ActiveWorkbook.Close savechanges:=false










--

Dave Peterson– Skjul sitert tekst –

– Vis sitert tekst –

Thanks to you both - it really did the job :)
 

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