Hi,
I just wonder, I am using this VBA to open a file from a folder:
and then, I use this one to save as the file:Dim excel As excel.Application
Dim wb As excel.Workbook
Dim sht As excel.Worksheet
Dim f As Object
Set f = Application.FileDialog(3)
f.AllowMultiSelect = False
f.Show
Set excel = CreateObject("excel.Application")
Set wb = excel.Workbooks.Open(f.SelectedItems(1))
Set sht = wb.Worksheets("Sheet1")
Rows("1:999").Select
Selection.Delete Shift:=xlUp
sht.Activate
sht.Columns("A:L").Copy
Range("A1").PasteSpecial Paste:=xlPasteValues
Call Fre_Value
However, when I reopen that macro file, there is a popup for File Available to Edit, or the file that has been executed by the macro keep reopening behind.Dim save_as As Variant
Dim file_name As String
Dim ProgramName As String
file_name = ProgramName
' Get the file name.
save_as = Application.GetSaveAsFilename(file_name, _
FileFilter:="Excel Files,*.xlsx,All Files,*.*")
' See if the user canceled.
If save_as = False Then Exit Sub
' Save the file with the new name.
Application.DisplayAlerts = False
If LCase$(Right$(save_as, 4)) <> ".xlsx" Then
file_name = save_as & ".xlsx"
End If
ActiveWorkbook.SaveAs Filename:=save_as, FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
What am I missing in these code?
Bookmarks