我尝试在Excel中执行VBA代码,将我的工作表保存在特定位置的HTML中。 我这样做了,但我需要每隔3分钟自动保存一次,因为我已经拥有SQL并且我必须刷新它。
我的代码是:
Public Sub doIt()
hardCopyToNewBook
saveFile "C:\temp\fileName.html"
End Sub
Private Sub hardCopyToNewBook()
Dim tabs As Variant
Dim s As Worksheet
tabs = Array("Sheet1", "Sheet2")
Sheets(tabs).Copy
For Each s In ActiveWorkbook.Sheets
With s
.Cells.Copy
.Cells.PasteSpecial Paste:=xlPasteValues
End With
Next s
Application.CutCopyMode = False
End Sub
Private Sub saveFile(htmlFileName As String)
Application.DisplayAlerts = False
Application.DefaultWebOptions.SaveHiddenData = False
On Error Resume Next
Call ActiveWorkbook.SaveAs(Filename:=htmlFileName, FileFormat:=xlHtml)
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub
我想制作一个循环或其他东西......但我不知道如何。 你能帮我吗?