|
標準モジュールに貼り付けてお試しください。
Sub test()
Dim Wb As Workbook
Dim MyFullName As String, MyPath As String, MyFileName As String
Dim objFs As Object
Set objFs = CreateObject("Scripting.FileSystemObject")
ChDir CreateObject("WScript.Shell").SpecialFolders("MyDocuments")
MyFullName = Application.GetOpenFilename
If MyFullName = "False" Then Exit Sub
MyPath = objFs.GetParentFolderName(MyFullName)
MyFileName = objFs.GetFilename(MyFullName)
With Worksheets("sheet1").Range("C1")
.Formula = "='" & MyPath & "\[" & MyFileName & "]Sheet1'!A1"
.Value = .Value
End With
With Worksheets("sheet3").Range("A1")
.Formula = "='" & MyPath & "\[" & MyFileName & "]Sheet2'!A2"
.Value = .Value
End With
End Sub
|
|