rlcurlee67
New Member
- Joined
- Jun 1, 2022
- Messages
- 11
- Office Version
- 2013
- Platform
- Windows
I have a macro using the application.getopenfilename and it works great at selecting the file. But, I need to actually open the file copy from it and close it.
[
Dim myFile As String
Dim YourFolderPath As Variant
Dim rng As Range
Dim B46 As Variant
Set rng = Range(ActiveCell, ActiveCell)
Sheets("2022 Oil Production").Select
YourFolderPath = "X:\UTCS\Region\USA\Assets\GOM_DEV\Julia\SubSrfc\Rsvr_Mgmt-Surv\Surv-Data\Prod\St. Malo Morning Report - by Prod Date\2022"
ChDir YourFolderPath
ChDrive "X"
myFile = Application.GetOpenFilename
MsgBox "open" & myFile
Range("B46").Select
Selection.Copy
Windows("Project 3. Oil Production copy (003).xlsx").Activate
ActiveSheet.Paste
Windows("05-26-2022.xlsx").Activate
ActiveWindow.Close
]]
I keep getting an error.
[
Dim myFile As String
Dim YourFolderPath As Variant
Dim rng As Range
Dim B46 As Variant
Set rng = Range(ActiveCell, ActiveCell)
Sheets("2022 Oil Production").Select
YourFolderPath = "X:\UTCS\Region\USA\Assets\GOM_DEV\Julia\SubSrfc\Rsvr_Mgmt-Surv\Surv-Data\Prod\St. Malo Morning Report - by Prod Date\2022"
ChDir YourFolderPath
ChDrive "X"
myFile = Application.GetOpenFilename
MsgBox "open" & myFile
Range("B46").Select
Selection.Copy
Windows("Project 3. Oil Production copy (003).xlsx").Activate
ActiveSheet.Paste
Windows("05-26-2022.xlsx").Activate
ActiveWindow.Close
]]
I keep getting an error.