0
我試圖將數據從一個封閉的工作簿中的單元格複製到另一個工作簿,而無需打開原來的工作簿。擅長從封閉的工作簿複製單元格。
我的代碼顯示遠...工作,但我需要能夠將數據寫入打開的工作簿上的某個單元格。
Private Function GetValue(path, file, sheet, ref)
' Retrieves a value from a closed workbook
Dim arg As String
' Make sure the file exists
If Right(path, 1) <> "\" Then path = path & "\"
If Dir(path & file) = "" Then
GetValue = "File Not Found"
Exit Function
End If
' Create the argument
arg = "'" & path & "[" & file & "]" & sheet & "'!" & _
Range(ref).Range("A1").Address(, , xlR1C1)
' Execute an XLM macro
GetValue = ExecuteExcel4Macro(arg)
End Function
Sub TestGetValue2()
p = "F:\excel_Project"
f = "Book1.xlsx"
s = "Sheet1"
a = "A1"
GetValue(p, f, s, a) = ("A1")
End Sub
+ 1的值(第一個值)對於其他信息 –