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: 27
Default simple workbook create/copy queries

I had 3 questions realted to workbook copy/create:

1.I am trying to create a new new workbook and
simultaneously saving it. On using an already existing
name. I get run-time error 1004...

I also used Application.DisplayAlerts = False
but still Application.DisplayAlerts shows true to
me.

OTherwise how can i trap this 1004 error for file already
existing error. I cannot use directly 1004 ..because run-
tiem 1004 comes for lot many reasons. WHat is the error
number to trap it?

2.i am using the below code to copy multiple worksheets in
a newly created workbook
With Workbooks(fileSaveName).Worksheets
.Parent.Activate
On Error Resume Next
MsgBox "Now copying the selected Worksheets, to
the newly created workbook " & fileSaveName & "."
For i = 1 To totSht - 1
MsgBox Err.Number
If .Item(DataWorksheet1(i)) Is Nothing Then
DataWorksheet1(i).Copy After:=.Item(3)
Else
MsgBox "Error! Cannot copy the selected
sheets!"
End If
Next i
.Item("Sheet1").Delete
.Item("Sheet2").Delete
.Item("Sheet3").Delete
End With

If you notice I am using condition "If .Item(DataWorksheet1
(i)) Is Nothing Then" to enter into the loop which doesnt
make sense. If i try using "If err.number < 0 " this
fails...because it gives 0 at one time and 13 or 91 other
time. IF i simply write the copy statement then on any
error i cannot convey the user the message:
MsgBox "Error! Cannot copy the selected sheets!"

what condition can i use???

3. I am using :
DataWorksheet1(i).Copy After:=.Item(1)
to copy....i try using before or after it doenst make any
different on the way my sheets are being copied. My sheets
are being copied on left...whereas i want them to be
copied on the right..how can i achieve this
Thanks tremendously...
 
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
create copy of sheet tab (excel 2007) when opening workbook jatman Excel Worksheet Functions 1 February 29th 08 12:26 PM
Create a macro to copy data from one workbook to another uha Excel Discussion (Misc queries) 1 November 5th 07 10:29 PM
Workbook with different queries on each worksheet Bettie Claxton New Users to Excel 0 August 23rd 07 06:56 PM
Workbook with 20+ queries of Access is TOO BIG Kevin76 Excel Discussion (Misc queries) 0 April 26th 06 04:33 PM
Where can I learn how to create parameter queries in Excel? Mark Excel Discussion (Misc queries) 1 January 23rd 06 02:31 PM


All times are GMT +1. The time now is 01:31 AM.

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"