Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel saves to temp and then deletes the original, what's wrong?

Status
Not open for further replies.

artsi03

Instructor
Jan 19, 2005
20
0
0
FI
Hi,

I'm having a real problem running Excel. I have done a macro sheet to help input info. When I want to save the sheet, Excel asks if I want to save to a temp file. If I choose no, nothing will be saved. If I choose yes, Excel will write a file containing hex numbers as it's name, without extension and it deletes the original file.

Might I be running to this problem because of wrongly done VBA programming? I have only really basic macros. Or might this be a problem with Excel settings?

Thank you.
Artsi
 
Here's my VBA sheets if they are for any help. Thanks.

-----------------------------------------------------

Dim Scheduled_Time As Date

Private Sub Workbook_Open()
Schedule_Inactivity_Close
Schedule_Alusta
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Application.OnTime Scheduled_Time, "Inactivity_Close", , False
Schedule_Inactivity_Close
End Sub

Private Sub Schedule_Inactivity_Close()
Scheduled_Time = Now() + TimeValue("00:15")
Application.OnTime Scheduled_Time, "Inactivity_Close"
End Sub

-----------------------------------------------------

Private Sub Schedule_Alusta()
ActiveSheet.Protect Password:=4444, UserInterfaceOnly:=True
Selection.AutoFilter Field:=1
Selection.AutoFilter Field:=2
Selection.AutoFilter Field:=3
Selection.AutoFilter Field:=4
Selection.AutoFilter Field:=5
Selection.AutoFilter Field:=6
Selection.AutoFilter Field:=7
Selection.AutoFilter Field:=8
Selection.AutoFilter Field:=9
Selection.AutoFilter Field:=10
Selection.AutoFilter Field:=11
Selection.AutoFilter Field:=12
Selection.AutoFilter Field:=13
Range("F4").Select
ActiveCell.FormulaR1C1 = "14"
Range("E4").Select
Selection.ClearContents
Range("D4").Select
Selection.ClearContents
Range("C4").Select
ActiveCell.FormulaR1C1 = "=R[-3]C[-1]"
Range("B4").Select
Selection.ClearContents
Range("A4").Select
ActiveCell.FormulaR1C1 = "=R[5]C[2]+R[7]C[2]"
Range("B4").Select
End Sub


---------------------Modules----------------

Sub alusta()
'
' Makro1 Makro
'

'
ActiveSheet.Protect Password:=4444, UserInterfaceOnly:=True
Selection.AutoFilter Field:=1
Selection.AutoFilter Field:=2
Selection.AutoFilter Field:=3
Selection.AutoFilter Field:=4
Selection.AutoFilter Field:=5
Selection.AutoFilter Field:=6
Selection.AutoFilter Field:=7
Selection.AutoFilter Field:=8
Selection.AutoFilter Field:=9
Selection.AutoFilter Field:=10
Selection.AutoFilter Field:=11
Selection.AutoFilter Field:=12
Selection.AutoFilter Field:=13
Range("F4").Select
ActiveCell.FormulaR1C1 = "14"
Range("E4").Select
Selection.ClearContents
Range("D4").Select
Selection.ClearContents
Range("C4").Select
ActiveCell.FormulaR1C1 = "=R[-3]C[-1]"
Range("B4").Select
Selection.ClearContents
Range("A4").Select
ActiveCell.FormulaR1C1 = "=R[5]C[2]+R[7]C[2]"
Range("B4").Select
ActiveSheet.Protect Password:=4444, DrawingObjects:=True, Contents:=True, Scenarios:=True
' ActiveWorkbook.save

End Sub

-----------------------------------------------------

Sub varaa()
'
' varaa Makro
'

'
ActiveSheet.Protect Password:=4444, UserInterfaceOnly:=True
If Range("D4") > 0 Then
Range("G9").Select
Selection.Copy
Range("G11").Offset(Range("C9").Value).Select
Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("H9").Select
Application.CutCopyMode = False
Selection.Copy
Range("H11").Offset(Range("C9").Value).Select
Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("L9").Select
Application.CutCopyMode = False
Selection.Copy
Range("L11").Offset(Range("C9").Value).Select
Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("C4").Select
Application.CutCopyMode = False
Selection.Copy
Range("E11").Offset(Range("C9").Value).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("D4").Select
Application.CutCopyMode = False
Selection.Copy
Range("D11").Offset(Range("C9").Value).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("F4").Select
Application.CutCopyMode = False
Selection.Copy
Range("F11").Offset(Range("C9").Value).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E4").Select
Application.CutCopyMode = False
Selection.Copy
Range("I11").Offset(Range("C9").Value).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("B4").Select
Application.CutCopyMode = False
Selection.Copy
Range("B11").Offset(Range("C9").Value).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("A4").Select
Selection.Copy
Range("C11").Offset(Range("C9").Value).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("M7").Select
ActiveCell.FormulaR1C1 = "A Esansaari 2005"
Range("B4").Select
' ActiveWorkbook.save
Else
MsgBox "Ole hyvä, täytä laskun tiedot keltaiselle pohjalle sivuun ennen varauksen tekemistä."
End If
End Sub

-----------------------------------------------------

Sub Inactivity_Close()
ActiveSheet.Protect Password:=4444, UserInterfaceOnly:=True
ActiveWorkbook.save
ThisWorkbook.Close True
End Sub
 
I may be confused about what exactly is happening to your Excel spreadsheet. If I understand correctly: you have created an Excel workbook; in the VBA code for this workbook, you have created the macros; after creating them, you attempt to save your workbook. At this point, Excel gives you some sort of error message (perhaps?) and then asks you if you would like to save a temporary file.

I may be wrong on this, but I think this may be the result of Excel loosing access to the .xls file you previously saved. If you are accessing a file on a disk (or remote computer) and access to that file is interrupted, then you will be unable to save the workbook. I know some versions of Excel will leave a temporary file with a strange file name in certain circumstances.

A few comments:

1.When does this error occur? When you manually try to save the workbook or when your macros tell Excel to save the workbook?

2. What version of Excel are you using?

3. When posting code, try to only include what is relevant. In this case, when dealing with a save problem, you should probably only include code that deals with saving the workbook. And remember: Specific questions get quick answers.

Best of Luck,
Joseph
 
Dear Joseph,

You have understanded the problem right. The error occures while using a network drive (altough every other excel file openes from network correctly). The error comes when both manually or when Excel tells to save.

I am using version 2000 (9.0.2812)

At this point, I am not using a code that saves the sheet automatically. Still, I get the error. So I tought maybe it's somewhere else in my code. This is why I cut pasted everything. Sorry it came out so long, but I don't have a glue what could be the problem.

Thanks for helping out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top