View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
ehale ehale is offline
external usenet poster
 
Posts: 8
Default Saveas Not Working

Hi Dave,

Thanks for responding -- message boxes are a good idea.

The Saveas worked initially, then one user started having trouble and
suddenly multiple users (including me) had trouble. Now, It's back to
working with identical code and message boxes are confirming path and all are
correct. When the problem returns, which I'm guessing it will, I will use
the message boxes to see what's going on.

Thanks,
Erica
"Dave Peterson" wrote:

I'd guess that either the folder wasn't what you wanted when the user ok'd the
getfilesaveasname dialog or you didn't notice the full name of the workbook:

I'd add some msgboxes just to help with the debugging:

Dim ChosenFileName As Variant 'could be false if the user cancels
....

ChosenFileName = Application.GetSaveAsFilename(InitialFileName:=Tam File, _
filefilter:="Excel Files ,*.xls,", Title:="Save As")

If ChosenFileName = False Then
'user hit cancel
'what should happen
Else
MsgBox ChosenFileName
wb2.SaveAs Filename:=ChosenFileName, FileFormat:=xlWorkbookNormal
MsgBox wb2.FullName
End If



ehale wrote:

Hello,

I'm having a problem with SAVEAS in following code. Basically trying to Add
a new Workbook (wb2) so that I can move sheets to it from an existing
workbook (wb1). When running, I get the dialogue box asking me to save as in
the correct directory, and it seems to save, but at the end of the routine
the file doesn't exist in the directory. When I step through the code, I can
see at the point right after I get the SaveAs Dialogue box (wb2.SaveAs
ChosenFileName, xlWorkbookNormal) that the workbook still has it's original
default name assigned by the Workbooks.Add command (Book1.xls, or whatever it
is). Not sure how to troubleshoot this . . . I don't get any error.

Any help is very appreciated. Thanks in advance.

Dim CurrentPath As String
Dim Filename As Variant

'Store the current path
CurrentPath = CurDir

'Change the path to the one we want
SetCurrentDirectory "\\SRV1\RATER\Attach PIC Rater"


'setting activeworkbook (self-rater) as wb1
Set wb1 = ActiveWorkbook
wb1Name = ActiveWorkbook.Name

'Adding a new workbook to move Quote tab to
Dim wb2 As Workbook
Set wb2 = Workbooks.Add
tamfile = InputBox("Enter your Prospect Code", "Save As Prospect Code",
wb1Name)

ChosenFileName = Application.GetSaveAsFilename(tamfile, "Excel Files
(*.xls),*.xls,", , "Title")
wb2.SaveAs ChosenFileName, xlWorkbookNormal


--

Dave Peterson