View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Choose File To SaveAs

Looking at the code, isn't that the workbook that he says he wants to save
but says doesn't get saved.

--
Regards,
Tom Ogilvy


"JLGWhiz" wrote:

Be sure that when your code executes the Save As, that your code has the
revised data in the active worksheet/workbook. The Save As will apply to the
last worksheet/workbook that the code activated or selected.

"Nigel" wrote:

If you open a workbook and then use SaveAs you save the open book as the new
name - it then becomes the open book.

So the sequence might be....

Open Book1
SaveAs Book2
Open Book1

You now have two workbooks open Book1 the original and Book2 the
copy........

Code.....

Workbooks.Open Filename:="C:\Book1.xls"
ActiveWorkbook.SaveAs Filename:="C:\Book2.xls"
Workbooks.Open Filename:="C:\Book1.xls"



--
Cheers
Nigel



"John" wrote in message
...
Hi there,

I'm having a bit of trouble with a Save As file dialog. The problem is
that I'm creating a copy of a workbook and it's the new copy that I want
to "save as", but the original workbook is the one getting saved! Can
anyone tell me how to ensure that the copy gets saved and ond not the
other way round?

Thanks in advance

John


Code as follows:

Public Sub SaveInvoice()
Dim FD As FileDialog
Dim wkbNewInvoice As Workbook
Dim wkbCurrent As Workbook

Set wkbCurrent = ThisWorkbook
Set wkbNewInvoice = Application.Workbooks.Add
wkbCurrent.Worksheets("Invoice").Copy Befo=wkbNewInvoice.Sheets(1)
Set FD = Application.FileDialog(msoFileDialogSaveAs)

With FD
'.Filters.Add "*.xls", 1
.InitialView = msoFileDialogViewDetails
.InitialFileName =
wkbCurrent.Worksheets("Variables").Range("Invoices Path").Value
If .Show Then
.Execute
End If
End With

End Sub