Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Saving a worksheet

Hi,

I want to save a worksheet in a workbook as a separate excel file containing
that one sheet, when a button is clicked. The code i have is:

Do
fName = Application.GetSaveAsFilename
Loop Until fName < False Or msoButtonSetOkCancel = Cancel

But it doesn't seem to work properly. Can anyone help?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Saving a worksheet

Remove the cancel test

Do
fname = Application.GetSaveAsFilename
Loop Until fname < False


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Gina" wrote in message
...
Hi,

I want to save a worksheet in a workbook as a separate excel file

containing
that one sheet, when a button is clicked. The code i have is:

Do
fName = Application.GetSaveAsFilename
Loop Until fName < False Or msoButtonSetOkCancel = Cancel

But it doesn't seem to work properly. Can anyone help?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Saving a worksheet

That's what I had before but it always asks to save the new file twice. Also
if I want to cancel the save it just keeps looping which is why I added the
last bit:

Or msoButtonSetOkCancel = Cancel.

Any more suggestions?

"Bob Phillips" wrote:

Remove the cancel test

Do
fname = Application.GetSaveAsFilename
Loop Until fname < False


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Gina" wrote in message
...
Hi,

I want to save a worksheet in a workbook as a separate excel file

containing
that one sheet, when a button is clicked. The code i have is:

Do
fName = Application.GetSaveAsFilename
Loop Until fName < False Or msoButtonSetOkCancel = Cancel

But it doesn't seem to work properly. Can anyone help?

Thanks




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Saving a worksheet

You need to test fname after the loop to decide what action to take. I have
no idea why it asks to save it twice, you don't show that code.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Gina" wrote in message
...
That's what I had before but it always asks to save the new file twice.

Also
if I want to cancel the save it just keeps looping which is why I added

the
last bit:

Or msoButtonSetOkCancel = Cancel.

Any more suggestions?

"Bob Phillips" wrote:

Remove the cancel test

Do
fname = Application.GetSaveAsFilename
Loop Until fname < False


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Gina" wrote in message
...
Hi,

I want to save a worksheet in a workbook as a separate excel file

containing
that one sheet, when a button is clicked. The code i have is:

Do
fName = Application.GetSaveAsFilename
Loop Until fName < False Or msoButtonSetOkCancel = Cancel

But it doesn't seem to work properly. Can anyone help?

Thanks






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Saving a worksheet

This is the complete macro code:

Sub SaveAs()

dim wsoutput as worksheet
Set wsOutput = Worksheets("output")

wsOutput.Select
wsOutput.Copy

Cells.Select
Range("K1").Activate
ActiveWorkbook.Colors(53) = RGB(247, 252, 255)
Range("K1").Select

Do
fName = Application.GetSaveAsFilename
Loop Until fName < False 'Or msoButtonSetOkCancel = Cancel

ActiveWindow.Close

End Sub

"Bob Phillips" wrote:

You need to test fname after the loop to decide what action to take. I have
no idea why it asks to save it twice, you don't show that code.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Gina" wrote in message
...
That's what I had before but it always asks to save the new file twice.

Also
if I want to cancel the save it just keeps looping which is why I added

the
last bit:

Or msoButtonSetOkCancel = Cancel.

Any more suggestions?

"Bob Phillips" wrote:

Remove the cancel test

Do
fname = Application.GetSaveAsFilename
Loop Until fname < False


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Gina" wrote in message
...
Hi,

I want to save a worksheet in a workbook as a separate excel file
containing
that one sheet, when a button is clicked. The code i have is:

Do
fName = Application.GetSaveAsFilename
Loop Until fName < False Or msoButtonSetOkCancel = Cancel

But it doesn't seem to work properly. Can anyone help?

Thanks








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Saving a worksheet

This should be what you want

Do
fname = Application.GetSaveAsFilename
Loop Until fname < False

If fname < False Then
ActiveWorkbook.SaveAs fname
ActiveWorkbook.Close savechanges:=False
End If


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Gina" wrote in message
...
This is the complete macro code:

Sub SaveAs()

dim wsoutput as worksheet
Set wsOutput = Worksheets("output")

wsOutput.Select
wsOutput.Copy

Cells.Select
Range("K1").Activate
ActiveWorkbook.Colors(53) = RGB(247, 252, 255)
Range("K1").Select

Do
fName = Application.GetSaveAsFilename
Loop Until fName < False 'Or msoButtonSetOkCancel = Cancel

ActiveWindow.Close

End Sub

"Bob Phillips" wrote:

You need to test fname after the loop to decide what action to take. I

have
no idea why it asks to save it twice, you don't show that code.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Gina" wrote in message
...
That's what I had before but it always asks to save the new file

twice.
Also
if I want to cancel the save it just keeps looping which is why I

added
the
last bit:

Or msoButtonSetOkCancel = Cancel.

Any more suggestions?

"Bob Phillips" wrote:

Remove the cancel test

Do
fname = Application.GetSaveAsFilename
Loop Until fname < False


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Gina" wrote in message
...
Hi,

I want to save a worksheet in a workbook as a separate excel file
containing
that one sheet, when a button is clicked. The code i have is:

Do
fName = Application.GetSaveAsFilename
Loop Until fName < False Or msoButtonSetOkCancel = Cancel

But it doesn't seem to work properly. Can anyone help?

Thanks








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Saving a worksheet

thanks for your help. I changed it abit and it works:

Do
fname = Application.GetSaveAsFilename
Loop Until fname < False Or msoButtonSetCancel


"Bob Phillips" wrote:

This should be what you want

Do
fname = Application.GetSaveAsFilename
Loop Until fname < False

If fname < False Then
ActiveWorkbook.SaveAs fname
ActiveWorkbook.Close savechanges:=False
End If


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Gina" wrote in message
...
This is the complete macro code:

Sub SaveAs()

dim wsoutput as worksheet
Set wsOutput = Worksheets("output")

wsOutput.Select
wsOutput.Copy

Cells.Select
Range("K1").Activate
ActiveWorkbook.Colors(53) = RGB(247, 252, 255)
Range("K1").Select

Do
fName = Application.GetSaveAsFilename
Loop Until fName < False 'Or msoButtonSetOkCancel = Cancel

ActiveWindow.Close

End Sub

"Bob Phillips" wrote:

You need to test fname after the loop to decide what action to take. I

have
no idea why it asks to save it twice, you don't show that code.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Gina" wrote in message
...
That's what I had before but it always asks to save the new file

twice.
Also
if I want to cancel the save it just keeps looping which is why I

added
the
last bit:

Or msoButtonSetOkCancel = Cancel.

Any more suggestions?

"Bob Phillips" wrote:

Remove the cancel test

Do
fname = Application.GetSaveAsFilename
Loop Until fname < False


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Gina" wrote in message
...
Hi,

I want to save a worksheet in a workbook as a separate excel file
containing
that one sheet, when a button is clicked. The code i have is:

Do
fName = Application.GetSaveAsFilename
Loop Until fName < False Or msoButtonSetOkCancel = Cancel

But it doesn't seem to work properly. Can anyone help?

Thanks









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
Saving in 1 worksheet only Mr. Burton Excel Worksheet Functions 11 October 21st 08 12:19 PM
Saving a worksheet JONESAROB Excel Discussion (Misc queries) 2 August 3rd 06 07:59 PM
Saving Worksheet Bobby28 Excel Discussion (Misc queries) 2 April 20th 05 09:55 PM
worksheet saving DYeomans Excel Discussion (Misc queries) 1 April 20th 05 08:04 AM
Saving a Worksheet GoBucks Excel Discussion (Misc queries) 3 January 27th 05 07:37 PM


All times are GMT +1. The time now is 06:36 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"