LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default quit on error

When I open Workbook2 (WB2) I need for it to check and see if Workbook1 (WB1)
exists and if so, I need for data to be updated. I have the following code;

On Error Resume Next
Workbooks.Open ("C:\path\wb1"), Password:="xxx"
Sheets("sheet1").Select
Cells.Select
Selection.Copy
Windows("wb2.xls").Activate
Sheets("data").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Workbooks("wb1.xls").Close True
Kill ("C:\path\WB1.xls")
On Error goto 0

It works fine if WB1 exists. However if WB1 does not exist it removes all
the data in WB2 Sheets("data"). I need for it to somehow quit all together
when it errors on
"Workbooks.Open ("C:\path\wb1"), Password:="xxx"" when the workbook does
not exist.

Any help is very much appreciated.


 
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
vba advice how 2get a input box to quit by entering the word quit+ 4 a msgbox to disp RELWOD85[_4_] Excel Programming 3 August 1st 05 07:11 PM
Quit solomon_monkey[_2_] Excel Programming 7 July 6th 05 05:18 PM
Excel97 not quit biu Excel Programming 2 May 23rd 04 05:26 PM


All times are GMT +1. The time now is 06:37 PM.

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"