borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (2 textbox to populate combobox)Next Topic (Pass Macro from Template to Document?) New Topic New Poll Post Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : Trying to import CSV file into excel
Poster Message
tsunamisurfer
Level: Guest


icon Trying to import CSV file into excel

Hi,

I'm a bit new to VB and I'm having trouble importing a CSV into a workbook.

Actually importing a known CSV is relatively easy but the CSV that I wish to import changes names each time (date-stamped).

So what I'd like to to get VB to bring up the Open File window, that I may be able to select the appropriate file at the appropriate location.

I've tried with this line of code below but it will not actually open the file after clicking the open button.

varFile = Application.GetOpenFilename

Can anyone help? Any help is appreciated.

The rest of my code below.....but the macro already specifies which filename, I would like the user to specify the CSV file

Sub CSV_Import()
'
' CSV_Import Macro
'

'
    Sheets("Bucket Totals").Select
    Cells.Select
    Selection.Clear
    Range("A1").Select
    Workbooks.Open FileName:="DrojexVBAAFS2_CUSTODY_BALANCES_01072003.CSV"
    Cells.Select
    Selection.Copy
    ActiveWindow.Close
    ActiveSheet.Paste
    Cells.Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .ShrinkToFit = False
        .MergeCells = False
    End With
    Cells.EntireColumn.AutoFit
    Rows("1:5").Select
    Range("A5").Activate
    Selection.Delete Shift:=xlUp
End Sub

Regards

03-07-2003 at 04:55 AM
| Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: Trying to import CSV file into excel

Try using the "common dialogue control" in vb.

Post back if you're stuck using.


Cheers Steve  

[Edited by steve_w on 03-07-2003 at 11:07 AM GMT]

03-07-2003 at 11:07 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : Trying to import CSV file into excel
Previous Topic (2 textbox to populate combobox)Next Topic (Pass Macro from Template to Document?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder