Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Why can't locate the file?

I have the following code that copies data to another workbook, then saves
the file as the employee name in cell C2. The user can define the location
the file saves.

Private Sub CommandButton4_Click()
'rCell Makes a copy of the initial calculations and saves to the Data
worksheet
'rFound looks for a duplicate date and if found copies over it else copies
to next avail row
Dim rCell As Range
Dim rFound As Range
With Application.ThisWorkbook
Set rFound =
..Worksheets("Data").Columns("B").Find(What:=(.Wor ksheets("STD Calc") _
.Range("C6")), LookAt:=xlWhole, LookIn:=xlFormulas)
If rFound Is Nothing Then
Set rCell =
..Worksheets("Data").Range("A65536").End(xlUp).Off set(1, 0)
Else
Set rCell = rFound.Offset(-3, -1)
End If
Worksheets("STD Calc").Range("B17:P37").Copy
rCell.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
End With
'the following opens the "Save As" MsgBox in Excel so the user
'can save to the location they desire. File is saved as name of employee in
cell C2
Dim RetVal As Variant
RetVal = Application.GetSaveAsFilename(Range("C2"))
If RetVal < False Then
ThisWorkbook.SaveAs RetVal
End If

End Sub

The problem I have is after saving the file to the desired location the file
is saved as type "File" not .xls. I don't know what that means exactly.
However when the file is opened for a second time and changes made, then the
user clicks the Save command button which fires the above code, and I get a
runtime error saying Unable to locate file "employee name".

Why can't it open the file? If I close and go to the file and open it is
fine. I just can't replicate the code above a second time.

Thanks for your help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Why can't locate the file?

try changing
ThisWorkbook.SaveAs RetVal

to

ThisWorkbook.SaveAs RetVal, xlworkbookNormal

--
regards,
Tom Ogilvy


"TimN" wrote:

I have the following code that copies data to another workbook, then saves
the file as the employee name in cell C2. The user can define the location
the file saves.

Private Sub CommandButton4_Click()
'rCell Makes a copy of the initial calculations and saves to the Data
worksheet
'rFound looks for a duplicate date and if found copies over it else copies
to next avail row
Dim rCell As Range
Dim rFound As Range
With Application.ThisWorkbook
Set rFound =
.Worksheets("Data").Columns("B").Find(What:=(.Work sheets("STD Calc") _
.Range("C6")), LookAt:=xlWhole, LookIn:=xlFormulas)
If rFound Is Nothing Then
Set rCell =
.Worksheets("Data").Range("A65536").End(xlUp).Offs et(1, 0)
Else
Set rCell = rFound.Offset(-3, -1)
End If
Worksheets("STD Calc").Range("B17:P37").Copy
rCell.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
End With
'the following opens the "Save As" MsgBox in Excel so the user
'can save to the location they desire. File is saved as name of employee in
cell C2
Dim RetVal As Variant
RetVal = Application.GetSaveAsFilename(Range("C2"))
If RetVal < False Then
ThisWorkbook.SaveAs RetVal
End If

End Sub

The problem I have is after saving the file to the desired location the file
is saved as type "File" not .xls. I don't know what that means exactly.
However when the file is opened for a second time and changes made, then the
user clicks the Save command button which fires the above code, and I get a
runtime error saying Unable to locate file "employee name".

Why can't it open the file? If I close and go to the file and open it is
fine. I just can't replicate the code above a second time.

Thanks for your help!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Why can't locate the file?

Tim,
It is saved in the Excel file format, but because you are not adding a file
extension (.xls) to the filename, when you see in Explorer, Window has no
idea what type of file it is, as Windows only looks at the extension, not
inside the file, so it gives the file the generic "File" type.
So specificy the filename as RetVal & ".xls".

NickHk
P.S. To me, one of the many reason not to "Hide nown extension" in Windows.
That way it would have more noticable that there was no extension on the
filename.


"TimN" ...
I have the following code that copies data to another workbook, then saves
the file as the employee name in cell C2. The user can define the
location
the file saves.

Private Sub CommandButton4_Click()
'rCell Makes a copy of the initial calculations and saves to the Data
worksheet
'rFound looks for a duplicate date and if found copies over it else copies
to next avail row
Dim rCell As Range
Dim rFound As Range
With Application.ThisWorkbook
Set rFound =
.Worksheets("Data").Columns("B").Find(What:=(.Work sheets("STD Calc") _
.Range("C6")), LookAt:=xlWhole, LookIn:=xlFormulas)
If rFound Is Nothing Then
Set rCell =
.Worksheets("Data").Range("A65536").End(xlUp).Offs et(1, 0)
Else
Set rCell = rFound.Offset(-3, -1)
End If
Worksheets("STD Calc").Range("B17:P37").Copy
rCell.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
End With
'the following opens the "Save As" MsgBox in Excel so the user
'can save to the location they desire. File is saved as name of employee
in
cell C2
Dim RetVal As Variant
RetVal = Application.GetSaveAsFilename(Range("C2"))
If RetVal < False Then
ThisWorkbook.SaveAs RetVal
End If

End Sub

The problem I have is after saving the file to the desired location the
file
is saved as type "File" not .xls. I don't know what that means exactly.
However when the file is opened for a second time and changes made, then
the
user clicks the Save command button which fires the above code, and I get
a
runtime error saying Unable to locate file "employee name".

Why can't it open the file? If I close and go to the file and open it is
fine. I just can't replicate the code above a second time.

Thanks for your help!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Why can't locate the file?

Still the same.

I have an idea, don't know if this matters but.....
When you typically do a File, Save As you get the window that opens asking
for the file name and below that you have "Save as Type: Microsoft Excel
Workbook(*.xls)"

With my code I get "Save as Type: All Files(*.*)

Is that maybe the problem?

"Tom Ogilvy" wrote:

try changing
ThisWorkbook.SaveAs RetVal

to

ThisWorkbook.SaveAs RetVal, xlworkbookNormal

--
regards,
Tom Ogilvy


"TimN" wrote:

I have the following code that copies data to another workbook, then saves
the file as the employee name in cell C2. The user can define the location
the file saves.

Private Sub CommandButton4_Click()
'rCell Makes a copy of the initial calculations and saves to the Data
worksheet
'rFound looks for a duplicate date and if found copies over it else copies
to next avail row
Dim rCell As Range
Dim rFound As Range
With Application.ThisWorkbook
Set rFound =
.Worksheets("Data").Columns("B").Find(What:=(.Work sheets("STD Calc") _
.Range("C6")), LookAt:=xlWhole, LookIn:=xlFormulas)
If rFound Is Nothing Then
Set rCell =
.Worksheets("Data").Range("A65536").End(xlUp).Offs et(1, 0)
Else
Set rCell = rFound.Offset(-3, -1)
End If
Worksheets("STD Calc").Range("B17:P37").Copy
rCell.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
End With
'the following opens the "Save As" MsgBox in Excel so the user
'can save to the location they desire. File is saved as name of employee in
cell C2
Dim RetVal As Variant
RetVal = Application.GetSaveAsFilename(Range("C2"))
If RetVal < False Then
ThisWorkbook.SaveAs RetVal
End If

End Sub

The problem I have is after saving the file to the desired location the file
is saved as type "File" not .xls. I don't know what that means exactly.
However when the file is opened for a second time and changes made, then the
user clicks the Save command button which fires the above code, and I get a
runtime error saying Unable to locate file "employee name".

Why can't it open the file? If I close and go to the file and open it is
fine. I just can't replicate the code above a second time.

Thanks for your help!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Why can't locate the file?

xlworkbookNormal
tells excel to save it as a workbook.

If it makes you more comfortable you can do this as well


RetVal = Application.GetSaveAsFilename( _
InitialFilename:=Range("C2").Value & ".xls", _
filefilter:="Excel Files (*.xls), *.xls")


If c2 already contains the .xls extension, then you can remove that part
from the above


RetVal = Application.GetSaveAsFilename( _
InitialFilename:=Range("C2").Value, _
filefilter:="Excel Files (*.xls), *.xls")
--
Regards,
Tom Ogilvy




"TimN" wrote:

Still the same.

I have an idea, don't know if this matters but.....
When you typically do a File, Save As you get the window that opens asking
for the file name and below that you have "Save as Type: Microsoft Excel
Workbook(*.xls)"

With my code I get "Save as Type: All Files(*.*)

Is that maybe the problem?

"Tom Ogilvy" wrote:

try changing
ThisWorkbook.SaveAs RetVal

to

ThisWorkbook.SaveAs RetVal, xlworkbookNormal

--
regards,
Tom Ogilvy


"TimN" wrote:

I have the following code that copies data to another workbook, then saves
the file as the employee name in cell C2. The user can define the location
the file saves.

Private Sub CommandButton4_Click()
'rCell Makes a copy of the initial calculations and saves to the Data
worksheet
'rFound looks for a duplicate date and if found copies over it else copies
to next avail row
Dim rCell As Range
Dim rFound As Range
With Application.ThisWorkbook
Set rFound =
.Worksheets("Data").Columns("B").Find(What:=(.Work sheets("STD Calc") _
.Range("C6")), LookAt:=xlWhole, LookIn:=xlFormulas)
If rFound Is Nothing Then
Set rCell =
.Worksheets("Data").Range("A65536").End(xlUp).Offs et(1, 0)
Else
Set rCell = rFound.Offset(-3, -1)
End If
Worksheets("STD Calc").Range("B17:P37").Copy
rCell.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
End With
'the following opens the "Save As" MsgBox in Excel so the user
'can save to the location they desire. File is saved as name of employee in
cell C2
Dim RetVal As Variant
RetVal = Application.GetSaveAsFilename(Range("C2"))
If RetVal < False Then
ThisWorkbook.SaveAs RetVal
End If

End Sub

The problem I have is after saving the file to the desired location the file
is saved as type "File" not .xls. I don't know what that means exactly.
However when the file is opened for a second time and changes made, then the
user clicks the Save command button which fires the above code, and I get a
runtime error saying Unable to locate file "employee name".

Why can't it open the file? If I close and go to the file and open it is
fine. I just can't replicate the code above a second time.

Thanks for your help!

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
How do I locate a file containing 'great lakes'? Eugeseals Excel Discussion (Misc queries) 2 March 5th 10 01:56 PM
How can I delete links (I can't locate) from one file to another? Vin C. Excel Discussion (Misc queries) 1 April 25th 06 09:30 PM
How do I locate the excel sort file? Network Excel Discussion (Misc queries) 2 March 2nd 06 06:18 PM
How can I locate links in an excel file and fix if incorrect? mmoore Excel Discussion (Misc queries) 4 October 19th 05 08:44 PM
Locate Most Recent File andibevan Excel Programming 3 October 27th 04 12:13 PM


All times are GMT +1. The time now is 11:15 PM.

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"