0
원본 통합 문서를 열지 않고 닫힌 통합 문서의 셀에서 다른 통합 문서로 데이터를 복사하려고합니다.닫힌 통합 문서의 셀 복사가 뛰어납니다.
코드가 멀리 보여 ... 작동하지만 열린 통합 문서의 특정 셀에 데이터를 쓸 수 있어야합니다. 당신이 무엇이든 GetValue
함수가 반환하는 셀의 값을 설정하려면
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에서 값 (첫 번째 값)이 채워집니다. 추가 정보 –