首先,爲了更新和保存文件,你需要先打開它 - 所以當你說你不想「真的」時會有點混淆/矛盾打開」 Excel文件......我把它意味着你只是不想Excel應用程序列明你會想是這樣的:
Public Sub demoCode()
Dim excelApp As Excel.Application
Dim targetWB As Workbook
Dim targetRange As Range
'Create new Excel Application
Set excelApp = New Excel.Application
'Keep hidden
excelApp.Visible = False
'Have new Excel App open workbook
Set targetWB = excelApp.Workbooks.Open("C:\Filename.xlsm")
'Set targetRange to 1 row past the first sheet's usedrange
Set targetRange = targetWB.Sheets(1).Range(targetWB.Sheets(1).UsedRange.address)(targetWB.Sheets(1).UsedRange.Rows.Count + 1, 1)
'Paste @ targetRange
'Close and save workbook
targetWB.Close (True)
'Close Excel App
excelApp.Quit
End Sub
希望這有助於 TheSilkCode
請分享您打開的代碼部分並嘗試保存文件。 –
還有一部分,您將指針設置爲工作簿將會很有幫助。 –