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: 1
Default unwanted copy


I am trying to finalise my archive procedure and am facing two problems
that I would greatly appreciate a hand with.

Currently the procedure creates an archive of a master file and and
gives the user an option to not proceed if a file with the same name
already exists (msg box). However if the do not proceed option is taken
(NO) then I am left with the copied and unnamed file open.

How can I get rid of this unwanted copy and navigate back to a
specified sheet.

Thanks in advance for any input.



' creates archive copy of stage clearance master data in specified
location

Sub CreateArchive()

Dim Wb As Workbook
Dim ws As Worksheet
Dim sStr As String
Dim Res As Long
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim ws3 As Worksheet
Dim ws4 As Worksheet

Application.ScreenUpdating = False

Set Wb = Workbooks("Single Sheet.xls")relabeled
Set ws = Worksheets("Master")
Set ws1 = Worksheets("stageclearer 1")
Set ws2 = Worksheets("stageclearer 2")
Set ws3 = Worksheets("stageclearer 3")
Set ws4 = Worksheets("stageclearer 4")

sStr = Format(Date, "yymmdd") & " " & "Stage Clearer"

ws.Copy


ws1.UsedRange.Offset(1).Clear
ws2.UsedRange.Offset(1).Clear
ws3.UsedRange.Offset(1).Clear
ws4.UsedRange.Offset(1).Clear
ws.UsedRange.Offset(1).Clear

If file_exist("G:\" & sStr & ".xls")

Res = MsgBox("This file already Exists. " & _
"Do you want to overwrite it?", vbYesNo + vbCritical, "OVERWRITE
FILE")
If Res = vbYes Then


Application.DisplayAlerts = False
ActiveWorkbook.SaveAs "G:\" & sStr
ActiveWorkbook.Close

Application.DisplayAlerts = True

End If

Else

ActiveWorkbook.SaveAs "G:\" & sStr

Worksheets("Navigation").Select

End If

Application.ScreenUpdating = True

End Sub

Function file_exist(str As String)
If Len(Dir(str)) 0 Then
file_exist = True
Else
file_exist = False
End If
End Function


--
Kstalker
------------------------------------------------------------------------
Kstalker's Profile: http://www.excelforum.com/member.php...o&userid=24699
View this thread: http://www.excelforum.com/showthread...hreadid=385437

 
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
unwanted add-in Keith[_3_] Setting up and Configuration of Excel 1 September 22nd 09 03:53 AM
Unwanted Rounding Bigjohn Excel Discussion (Misc queries) 2 May 25th 06 10:34 AM
copy/paste excel to texteditor -> multi-line text cells gain unwanted double-quotes niz Excel Discussion (Misc queries) 1 October 14th 05 02:06 PM
Saving to network drive gives unwanted copy or overwrite message Bill Excel Discussion (Misc queries) 2 July 29th 05 02:25 AM
unwanted resizing when copy-pasting embedded charts holg3r Charts and Charting in Excel 4 June 4th 05 03:28 AM


All times are GMT +1. The time now is 07:20 PM.

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

About Us

"It's about Microsoft Excel"