PC Review


Reply
Thread Tools Rate Thread

deleteing peoblem

 
 
=?Utf-8?B?Q3VydA==?=
Guest
Posts: n/a
 
      4th Aug 2007
working in workbook useing this to create a sheet for mail merge in C:\Parade
Sheets("MailE").Select
Sheets("MailE").Copy
ActiveWorkbook.SaveAs Filename:= _
"C:\Parade\MailE.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
When I try to delete with this
Sub Maildel()
Worksheets("C:\Parade\MailE.xls").Select
Worksheets("C:\Parade\MailE.xls").Delete
End Sub
I get error 9 sub script out of range
Seems if I can put the worksheet there I should be able to delete it know
the path is correct This is being done from C;\Parade\Parade.xls ? Thanks All
 
Reply With Quote
 
 
 
 
=?Utf-8?B?T3NzaWVNYWM=?=
Guest
Posts: n/a
 
      4th Aug 2007
ActiveWorkbook.SaveAs Filename:= _
"C:\Parade\MailE.xls", ......
Above saves a workbook as a filename.

Workbooks are the files you save. Worksheets are the spreadsheets within the
workbook. I think that you have them mixed up.

The following refers to worksheets.

Worksheets("C:\Parade\MailE.xls").Select
Worksheets("C:\Parade\MailE.xls").Delete

If you are unsure of the syntax to complete the operation then try recording
a macro to do it. Note: You cannot delete a workbook while it is open.

Regards,

OssieMac




"Curt" wrote:

> working in workbook useing this to create a sheet for mail merge in C:\Parade
> Sheets("MailE").Select
> Sheets("MailE").Copy
> ActiveWorkbook.SaveAs Filename:= _
> "C:\Parade\MailE.xls", _
> FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
> ReadOnlyRecommended:=False, CreateBackup:=False
> When I try to delete with this
> Sub Maildel()
> Worksheets("C:\Parade\MailE.xls").Select
> Worksheets("C:\Parade\MailE.xls").Delete
> End Sub
> I get error 9 sub script out of range
> Seems if I can put the worksheet there I should be able to delete it know
> the path is correct This is being done from C;\Parade\Parade.xls ? Thanks All

 
Reply With Quote
 
=?Utf-8?B?T3NzaWVNYWM=?=
Guest
Posts: n/a
 
      4th Aug 2007
Sorry. Error in previous post. I don't think that you can record the workbook
delete process.

Regards,

OssieMac

"Curt" wrote:

> working in workbook useing this to create a sheet for mail merge in C:\Parade
> Sheets("MailE").Select
> Sheets("MailE").Copy
> ActiveWorkbook.SaveAs Filename:= _
> "C:\Parade\MailE.xls", _
> FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
> ReadOnlyRecommended:=False, CreateBackup:=False
> When I try to delete with this
> Sub Maildel()
> Worksheets("C:\Parade\MailE.xls").Select
> Worksheets("C:\Parade\MailE.xls").Delete
> End Sub
> I get error 9 sub script out of range
> Seems if I can put the worksheet there I should be able to delete it know
> the path is correct This is being done from C;\Parade\Parade.xls ? Thanks All

 
Reply With Quote
 
=?Utf-8?B?Q3VydA==?=
Guest
Posts: n/a
 
      4th Aug 2007
The MailE I save is a worksheet from Parade.xls Is there a way to save this
so it may be deleted.
Thanks much for your responce

"OssieMac" wrote:

> Sorry. Error in previous post. I don't think that you can record the workbook
> delete process.
>
> Regards,
>
> OssieMac
>
> "Curt" wrote:
>
> > working in workbook useing this to create a sheet for mail merge in C:\Parade
> > Sheets("MailE").Select
> > Sheets("MailE").Copy
> > ActiveWorkbook.SaveAs Filename:= _
> > "C:\Parade\MailE.xls", _
> > FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
> > ReadOnlyRecommended:=False, CreateBackup:=False
> > When I try to delete with this
> > Sub Maildel()
> > Worksheets("C:\Parade\MailE.xls").Select
> > Worksheets("C:\Parade\MailE.xls").Delete
> > End Sub
> > I get error 9 sub script out of range
> > Seems if I can put the worksheet there I should be able to delete it know
> > the path is correct This is being done from C;\Parade\Parade.xls ? Thanks All

 
Reply With Quote
 
=?Utf-8?B?T3NzaWVNYWM=?=
Guest
Posts: n/a
 
      4th Aug 2007
Hi Curt,

If I understand correctly, you have a workbook called ‘Parade.xls’ and in
that workbook you have a worksheet called ‘MailE’.

Your first macro copies the worksheet ‘MailE’ to a new workbook and you save
the new workbook as ‘MailE.xls’. this should work.

In the Sub Maildel() you want to delete the workbook ‘MailE’ and this is not
working.

First of all the workbook ‘MailE.xls’ must be closed before you can delete
it. The following code should work. However, if the workbook is not open you
will get an error trying to activate it. You can either delete the first 2
lines or you can use the second procedure if you are not sure if it is open.

Sub Maildel()

Windows("MailE.xls").Activate
ActiveWindow.Close

‘The following line deletes a workbook.
Kill "C:\Parade\Parade\MailE.xls"

End Sub

'Alternative to handle error if workbook not open

Sub Maildel_2()

On Error Resume Next
Windows("MailE.xlsm").Activate
ActiveWindow.Close
On Error GoTo 0

Kill "c:\Parade\Parade\MailE.xls"

End Sub

Regards,

OssieMac

"Curt" wrote:

> The MailE I save is a worksheet from Parade.xls Is there a way to save this
> so it may be deleted.
> Thanks much for your responce
>
> "OssieMac" wrote:
>
> > Sorry. Error in previous post. I don't think that you can record the workbook
> > delete process.
> >
> > Regards,
> >
> > OssieMac
> >
> > "Curt" wrote:
> >
> > > working in workbook useing this to create a sheet for mail merge in C:\Parade
> > > Sheets("MailE").Select
> > > Sheets("MailE").Copy
> > > ActiveWorkbook.SaveAs Filename:= _
> > > "C:\Parade\MailE.xls", _
> > > FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
> > > ReadOnlyRecommended:=False, CreateBackup:=False
> > > When I try to delete with this
> > > Sub Maildel()
> > > Worksheets("C:\Parade\MailE.xls").Select
> > > Worksheets("C:\Parade\MailE.xls").Delete
> > > End Sub
> > > I get error 9 sub script out of range
> > > Seems if I can put the worksheet there I should be able to delete it know
> > > the path is correct This is being done from C;\Parade\Parade.xls ? Thanks All

 
Reply With Quote
 
=?Utf-8?B?T3NzaWVNYWM=?=
Guest
Posts: n/a
 
      4th Aug 2007
Curt,

Replace that second macro with this.

Sub Maildel_2()

On Error Resume Next
Windows("MailE.xls").Activate
ActiveWindow.Close
On Error GoTo 0

Kill "c:\Parade\Parade\MailE.xls"

End Sub

I was working with xl2007 and forgot to amend the file extension from xlsm
to xls.

Regards,

OssieMac


"Curt" wrote:

> The MailE I save is a worksheet from Parade.xls Is there a way to save this
> so it may be deleted.
> Thanks much for your responce
>
> "OssieMac" wrote:
>
> > Sorry. Error in previous post. I don't think that you can record the workbook
> > delete process.
> >
> > Regards,
> >
> > OssieMac
> >
> > "Curt" wrote:
> >
> > > working in workbook useing this to create a sheet for mail merge in C:\Parade
> > > Sheets("MailE").Select
> > > Sheets("MailE").Copy
> > > ActiveWorkbook.SaveAs Filename:= _
> > > "C:\Parade\MailE.xls", _
> > > FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
> > > ReadOnlyRecommended:=False, CreateBackup:=False
> > > When I try to delete with this
> > > Sub Maildel()
> > > Worksheets("C:\Parade\MailE.xls").Select
> > > Worksheets("C:\Parade\MailE.xls").Delete
> > > End Sub
> > > I get error 9 sub script out of range
> > > Seems if I can put the worksheet there I should be able to delete it know
> > > the path is correct This is being done from C;\Parade\Parade.xls ? Thanks All

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Odd Peoblem Windows XP Basics 0 26th Jan 2006 12:45 PM
peoblem nino Security Networking 1 15th Jun 2005 09:14 PM
DropDownList peoblem !? =?Utf-8?B?VGh1YmFpdGk=?= Microsoft ASP .NET 1 27th Dec 2004 12:59 PM
CD-ROM firmware peoblem! Valentin Stanev Windows XP Hardware 1 15th Oct 2003 12:19 AM
exception peoblem Nick Sedrak Microsoft Dot NET Framework 1 22nd Jul 2003 12:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:53 PM.