Unable to load .data file in excel using VBA
Results 1 to 8 of 8

Thread: Unable to load .data file in excel using VBA
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Aug 2019
    Posts
    20
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Unable to load .data file in excel using VBA

    Hello,

    I'm trying to build a dialog box where will ask me to load a .data file extension file which later on i will edit few things and save as .xlsx.

    Problem is that whenever the file is selected and supposed to be loaded, there is no outcome... it simply ends macro as if nothing happened.
    If i try go step by step, it will open the box, i choose the file, and then, empty ... its like if for some reason the data in the .data file is not loaded.

    basically the reason for open .data is so i can then edit in excel and turn data which will appear all in first column into a table by using the text into columns tool.

    Anyone knows why this .data file might not be loading? My VBA knowledge is very basic and its my first time working with dialog box option..

    To test i also tried to just record a macro and do all manually (open the file, edit it, close it and all) and when check macro step by step, it will not show data but keep going with everything else...

    Not sure if it makes sense but hopefully someone can help.

    Thanks in advance.

  2. #2
    Board Regular
    Join Date
    Nov 2006
    Location
    London
    Posts
    8,083
    Post Thanks / Like
    Mentioned
    20 Post(s)
    Tagged
    2 Thread(s)

    Default Re: Unable to load .data file in excel using VBA

    .CSV is a comma separated file
    .TXT is a text file
    .PDF is a Portable Document Format file

    What's a .data file ?
    Where did you get the file from?

    Excel needs to know what type of file .data is, some extensions it will recognise
    Last edited by Special-K99; Aug 16th, 2019 at 08:21 AM.

  3. #3
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling, Scotland
    Posts
    75,123
    Post Thanks / Like
    Mentioned
    60 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Unable to load .data file in excel using VBA

    Can you post your code?
    If posting code please use code tags.

  4. #4
    New Member
    Join Date
    Aug 2019
    Posts
    20
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Unable to load .data file in excel using VBA

    Quote Originally Posted by Special-K99 View Post
    .CSV is a comma separated file
    .TXT is a text file
    .PDF is a Portable Document Format file

    What's a .data file ?
    Where did you get the file from?

    Excel needs to know what type of file .data is, some extensions it will recognise
    .data is a DATA file, probably generated by some reporting tool.
    I just open Excel, and drag the .data file into it, and excel will read it, but will read it as text and have it all in 1 column, that's why then i just "text to columns" and make some edits.

    Wanted to try make some macro where i can load that .data file and make the changes needed and then be saved as .xlsx. Currently i do this manually and thought it could work with a macro and save some time.

    That's why i'm not sure why by using the dialogbox won't recognize it or load it.

  5. #5
    New Member
    Join Date
    Aug 2019
    Posts
    20
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Unable to load .data file in excel using VBA

    Code:
    
    Sub Get_Data()
    Dim filetoopen As Variant
    
    
    filetoopen = Application.GetOpenFilename _
    (Title:="Please choose a file to import", _
    FileFilter:="Excel Files *.data (*.data),")
    ''
    Workbooks.Open fileName:=filetoopen
    
    
    End Sub
    in theory this should prompt the folder and then i chose the file and then appear on excel.
    it lets me choose file, but then it just opens empty sheet.

    as i said its my first time using dialog box to prompt for a file to be opened and i guess rest of code i add should just be continued after that...

  6. #6
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling, Scotland
    Posts
    75,123
    Post Thanks / Like
    Mentioned
    60 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Unable to load .data file in excel using VBA

    Can you manually open a .data file from Excel?
    If posting code please use code tags.

  7. #7
    New Member
    Join Date
    Aug 2019
    Posts
    20
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Unable to load .data file in excel using VBA

    yes, and straight ahead will appear the box dialog to format it, and i just select delimited, choose separator and some other stuff and when finish it will display data as i wish.

    i tried closing all and restarting excel and for some reason seems to be working now.

    not sure why it wouldn't work before.

  8. #8
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling, Scotland
    Posts
    75,123
    Post Thanks / Like
    Mentioned
    60 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Unable to load .data file in excel using VBA

    So it's a text file?

    If that's the case you probably need to use Workbooks.OpenText rather than Workbooks.Open.
    Last edited by Norie; Aug 16th, 2019 at 09:59 AM.
    If posting code please use code tags.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •