Hello ,
Wondering if anyone out there could come to the assistance of a vba newbie.
I have a getopenfilename program that opens a dialog box and enbles me to choose a file that opens up. From there.I copy a sheet to another worksheet.
However, how do I close the file retrieved through the GetOpenFilename method after copying data from it. More importantly,what code would I have to use to basically close "any" file chosen thru the GetOpenFilename method.
Also how do I choose two files from the open dialog box at the same time?Tried changing mutiselect to true in the GetOpenFilename expression but doesn't make a difference.The two files i want to choose are in different folders.Is that a problem?
Here is my code so far:
Sub mnuFileOpen_Click()
Dim FullFileName As String
FullFileName = Application.GetOpenFilename("Excel Files (*.xls),*.xls", True)
Application.StatusBar = "Opening " & FullFileName
Workbooks.Open FullFileName
Sheets(1).Range("A:H").Copy
Workbooks("Trading Accounts.xls").Activate
Sheets("FMA Data").Select
Range("A1").Select
Selection.PasteSpecial xlValues
'Workbooks("Trading Accounts.xls").Sheets("FMA Data").Range("A1").PasteSpecial xlValues
Application.CutCopyMode = False
Application.StatusBar = "Closing " & FullFileName
Application.Windows(FullFileName).Close
Application.StatusBar = False
End Sub
Thanks for your time.
romij29
Wondering if anyone out there could come to the assistance of a vba newbie.
I have a getopenfilename program that opens a dialog box and enbles me to choose a file that opens up. From there.I copy a sheet to another worksheet.
However, how do I close the file retrieved through the GetOpenFilename method after copying data from it. More importantly,what code would I have to use to basically close "any" file chosen thru the GetOpenFilename method.
Also how do I choose two files from the open dialog box at the same time?Tried changing mutiselect to true in the GetOpenFilename expression but doesn't make a difference.The two files i want to choose are in different folders.Is that a problem?
Here is my code so far:
Sub mnuFileOpen_Click()
Dim FullFileName As String
FullFileName = Application.GetOpenFilename("Excel Files (*.xls),*.xls", True)
Application.StatusBar = "Opening " & FullFileName
Workbooks.Open FullFileName
Sheets(1).Range("A:H").Copy
Workbooks("Trading Accounts.xls").Activate
Sheets("FMA Data").Select
Range("A1").Select
Selection.PasteSpecial xlValues
'Workbooks("Trading Accounts.xls").Sheets("FMA Data").Range("A1").PasteSpecial xlValues
Application.CutCopyMode = False
Application.StatusBar = "Closing " & FullFileName
Application.Windows(FullFileName).Close
Application.StatusBar = False
End Sub
Thanks for your time.
romij29