Hi, i just want to import an xls file, but thru an macro, and after i import
the file, i will add some codes myself. I need to hit a button linked to an
macro and the macro to open an browse window. I will select the file i need,
hit ok and the excel to import in active sheet, that file. After this, the
macro will format the content, but this is another problem i will deal with
later. I only need the macro to import a file by browsing after it.
Can this be done?
Thanks!
"Dave Peterson" a scris:
Chip's code shows you how to get the name of the file from the user. It doesn't
do the actual import.
You'll have to add that portion yourself -- or explain what you're doing in
greater detail.
puiuluipui wrote:
Hi, i have some problems.
The code run corectly and browse for whatever file i need, but when i click
that file, it doesn;t import anything!
What am i doing wrong? I have excel 2003.
Thanks!
"Chip Pearson" a scris:
Try some code like the following:
Sub AAA()
Dim FName As Variant
Dim Filter As String
' Excel 2003 workbooks
Filter = "Excel Files (*.xls),*.xls"
' Excel 2007 workbooks workbooks
Filter = "Excel Files (*.xlsx;*.xlsm;*.xlsb),*.xlsx;*.xlsm;*.xlsb"
' Excel 2003 and 2007
Filter = "Excel Files
(*.xls;*.xlsx;*.xlsm;*.xlsb),*.xls;*.xlsx;*.xlsm;* .xlsb"
FName = Application.GetOpenFilename(filefilter:=Filter)
If FName = False Then
Debug.Print "cancel"
Else
Debug.Print "selected: " & FName
End If
End Sub
Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
On Wed, 31 Mar 2010 14:00:01 -0700, puiuluipui
wrote:
Hi, i need a macro to import another xls file.When i run macro i need a
window to appear and to browse to the file i need to import. I allways open
another file, so i want to browse for the file.
Can this be done?
Thanks!
.
--
Dave Peterson
.