我有一个挑战,至少对我来说,我显然无法应对。有人可以帮助我或建议如何在 Excel 关闭时运行宏吗?
通过 VBA 关闭 Excel 时,如何使宏运行?
Sub Upload0()
    ' Upload Webpage content
    Application.OnTime Now + TimeValue("00:00:15"), "Upload0"
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://cetatenie.just.ro/ordine/articol-11", Destination:=Range("A1"))
        .Name = "CetatenieOrdine"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = True
        .BackgroundQuery = True
        .RefreshStyle = xlOverwriteCells
        .SavePassword = True
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 1
        .WebSelectionType = xlEntirePage
        .WebFormatting = xlWebFormattingNone
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
' Deletes empty cells
Columns("A:A").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Delete Shift:=xlUp
' Adjust column width and delet useless rows
Rows("1:31").Select
Selection.Delete Shift:=xlUp
Range("B28").Select
Selection.End(xlDown).Select
Rows("17:309").Select
Selection.Delete Shift:=xlUp
End Sub
非常感谢大家!