Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Saying No to Message Box prompt through VBA

Hi all,

I've created a VBA program which opens another Excel workbook and
copies data from two different tabs and pastes into my current
workbook. After all that is done, I try to close the source workbook,
but get a message box stating if I want to save changes to the
workbook. I want the VBA script to say no. I used application.sendkeys
("n") to accomplish this, but it doesn't work. I want to run this
program on a daily basis unattended, but as of now, the program stops
and waits for me to click No on the message box before proceeding. Any
and all help will be greatly appreciated!

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Saying No to Message Box prompt through VBA

Couple of methods.

1...............In Thisworkbook module of source workbook to close
without saving.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Saved = True
End Sub

2................In macro which closes the source workbook

Application.displayalerts = false

close the workbook

Application.displayalerts = true


Gord Dibben Microsoft Excel MVP

On Tue, 16 Aug 2011 14:43:43 -0700 (PDT), Haas C
wrote:

Hi all,

I've created a VBA program which opens another Excel workbook and
copies data from two different tabs and pastes into my current
workbook. After all that is done, I try to close the source workbook,
but get a message box stating if I want to save changes to the
workbook. I want the VBA script to say no. I used application.sendkeys
("n") to accomplish this, but it doesn't work. I want to run this
program on a daily basis unattended, but as of now, the program stops
and waits for me to click No on the message box before proceeding. Any
and all help will be greatly appreciated!

Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default Saying No to Message Box prompt through VBA

Just a comment on Gord's option 1: With this code, if you open the
workbook manually, enter any changes and close the workbook (without
doing a manual save) the workbook will obediently close without saving
the changes.

Clif

"Gord" wrote in message
...
Couple of methods.

1...............In Thisworkbook module of source workbook to close
without saving.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Saved = True
End Sub

2................In macro which closes the source workbook

Application.displayalerts = false

close the workbook

Application.displayalerts = true


Gord Dibben Microsoft Excel MVP

On Tue, 16 Aug 2011 14:43:43 -0700 (PDT), Haas C
wrote:

Hi all,

I've created a VBA program which opens another Excel workbook and
copies data from two different tabs and pastes into my current
workbook. After all that is done, I try to close the source workbook,
but get a message box stating if I want to save changes to the
workbook. I want the VBA script to say no. I used application.sendkeys
("n") to accomplish this, but it doesn't work. I want to run this
program on a daily basis unattended, but as of now, the program stops
and waits for me to click No on the message box before proceeding. Any
and all help will be greatly appreciated!

Thanks!




--
Clif McIrvin

(clare reads his mail with moe, nomail feeds the bit bucket :-)


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Saying No to Message Box prompt through VBA


Thank you very much - I used the second method and it worked
perfectly! Thanks!

On Aug 16, 5:59*pm, Gord wrote:
Couple of methods.

1...............In Thisworkbook module of source workbook to close
without saving.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
* * * * * ThisWorkbook.Saved = True
End Sub

2................In macro which closes the source workbook

Application.displayalerts = false

* * * * *close the workbook

Application.displayalerts = true

Gord Dibben * *Microsoft Excel MVP

On Tue, 16 Aug 2011 14:43:43 -0700 (PDT), Haas C



wrote:
Hi all,


I've created a VBA program which opens another Excel workbook and
copies data from two different tabs and pastes into my current
workbook. After all that is done, I try to close the source workbook,
but get a message box stating if I want to save changes to the
workbook. I want the VBA script to say no. I used application.sendkeys
("n") to accomplish this, but it doesn't work. I want to run this
program on a daily basis unattended, but as of now, the program stops
and waits for me to click No on the message box before proceeding. Any
and all help will be greatly appreciated!


Thanks!- Hide quoted text -


- Show quoted text -


T
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Saying No to Message Box prompt through VBA

Haas C formulated on Tuesday :
Hi all,

I've created a VBA program which opens another Excel workbook and
copies data from two different tabs and pastes into my current
workbook. After all that is done, I try to close the source workbook,
but get a message box stating if I want to save changes to the
workbook. I want the VBA script to say no. I used application.sendkeys
("n") to accomplish this, but it doesn't work. I want to run this
program on a daily basis unattended, but as of now, the program stops
and waits for me to click No on the message box before proceeding. Any
and all help will be greatly appreciated!

Thanks!


Workbooks("NameGoesHere.xls").Close SaveChanges:=False

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Saying No to Message Box prompt through VBA

Cliff

OP stated he wanted to close the source workbook and say NO to saving.

I try to close the source workbook,
but get a message box stating if I want to save changes to the
workbook. I want the VBA script to say no.


Just complying with his wishes.


Gord

On Tue, 16 Aug 2011 17:15:03 -0500, "Clif McIrvin"
wrote:

Just a comment on Gord's option 1: With this code, if you open the
workbook manually, enter any changes and close the workbook (without
doing a manual save) the workbook will obediently close without saving
the changes.

Clif

"Gord" wrote in message
.. .
Couple of methods.

1...............In Thisworkbook module of source workbook to close
without saving.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Saved = True
End Sub

2................In macro which closes the source workbook

Application.displayalerts = false

close the workbook

Application.displayalerts = true


Gord Dibben Microsoft Excel MVP

On Tue, 16 Aug 2011 14:43:43 -0700 (PDT), Haas C
wrote:

Hi all,

I've created a VBA program which opens another Excel workbook and
copies data from two different tabs and pastes into my current
workbook. After all that is done, I try to close the source workbook,
but get a message box stating if I want to save changes to the
workbook. I want the VBA script to say no. I used application.sendkeys
("n") to accomplish this, but it doesn't work. I want to run this
program on a daily basis unattended, but as of now, the program stops
and waits for me to click No on the message box before proceeding. Any
and all help will be greatly appreciated!

Thanks!

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Saying No to Message Box prompt through VBA

Gord has brought this to us :
OP stated he wanted to close the source workbook and say NO to saving.

I try to close the source workbook,
but get a message box stating if I want to save changes to the
workbook. I want the VBA script to say no.


Just complying with his wishes.


Gord


So why not use the SaveChanges arg for the Close method? Surely this
would be preferable over adding code to the xls so it fires a security
warning when opened. Also, it occupies the same line of code, obviating
the need to turn DisplayAlerts off/on and so saves the extra
processing.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Message Box Prompt yasser Excel Programming 1 October 13th 06 12:33 AM
help with message prompt Monty New Users to Excel 1 September 9th 05 10:03 AM
Message prompt in VBA ltong Excel Programming 4 October 6th 04 05:16 PM
Disable Message Prompt in VBA ltong Excel Programming 6 October 3rd 04 11:41 AM
Deleting a Prompt Message LC[_2_] Excel Programming 2 July 18th 03 09:46 PM


All times are GMT +1. The time now is 02:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"