Thread: [Solved] Optional File Browsing
View Single Post
 
Old 03-06-2011, 06:11 PM
judicial85 judicial85 is offline Windows 7 Office 2010 (Version 14.0)
Advanced Beginner
 
Join Date: Nov 2010
Posts: 64
judicial85 is on a distinguished road
Default Optional File Browsing

Hello!

I currently have a macro that automatically imports "DATA.txt" off of the Desktop and into EXCEL. What I was thinking of was to add a subroutine that if "DATA.txt" was not found by the program, it would open a file browsing window so the user can select the file themselves.

Can someone help with that?
Thanks, Bryan

(Current code piece)
Code:
'IMPORT the file from desktop (DATA.txt)
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;C:\Users\BK\Desktop\DATA.txt", Destination:=Range("$A$1"))
        .name = "dos"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 850
        .TextFileStartRow = 1
        .TextFileParseType = xlFixedWidth
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1, 1, 1)
        .TextFileFixedColumnWidths = Array(13, 12)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With
Reply With Quote