iFolder$ = "C:\" & Worksheets("ЭЛЕКТРИЧЕСТВО").[D20] & " Электроэнергия\"
iFilename$ = iFolder$ & [D14] & ".xls"
ActiveWorkbook.SaveAs iFilename$, xlWorkbookNormal 'xlNormal
ActiveWorkbook.Close True
Макрос Excel сохраняет файл по умолчанию, а не по прописанному пути
Sub Сохранить_Электроэнергия()
Application.ScreenUpdating = False
Sheets.Add.Name = "Лист1"
Sheets("ЭЛЕКТРИЧЕСТВО").Select
Cells.Select
Selection.Copy
Sheets("Лист1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A1").Select
ActiveSheet.Name = [D14]
On Error Resume Next
Folder$ = "C:\" & Sheets("ЭЛЕКТРИЧЕСТВО").Range("d20") & " Электроэнергия" & "\"
Filename = [D14] & ".xls"
Err.Clear: ActiveSheet.Copy: DoEvents
If Err Then Exit Sub
ActiveWorkbook.SaveAs Filename, xlWorkbookNormal
ActiveWorkbook.Close False
Sheets("ЭЛЕКТРИЧЕСТВО").Select
Range("D14").Select
Application.DisplayAlerts = False
Sheets(Range("D14").Value).Select
ActiveWindow.SelectedSheets.Delete
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Код:
Код:
iFilename$ = "C:\" & Worksheets("ЭЛЕКТРИЧЕСТВО").[D20] & " Электроэнергия\" & [D14] & ".xls"
ActiveWorkbook.Close True, iFilename$
ActiveWorkbook.Close True, iFilename$