Macro: Closing files without saving

  • Thread starter Thread starter Snoopy
  • Start date Start date
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
 
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
 
Try putting this line before you close the file:

Application.DisplayAlerts = False

and this one after:

Application.DisplayAlerts = True

Hope this helps.

Pete
 
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 :)
 
Back
Top