Unable to load .data file in excel using VBA

Dani_LobP

Board Regular
Joined
Aug 16, 2019
Messages
134
Office Version
  1. 365
Platform
  1. Windows
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.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
.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:
Upvote 0
.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.
 
Upvote 0
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...
 
Upvote 0
Can you manually open a .data file from Excel?
 
Upvote 0
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.
 
Upvote 0
So it's a text file?

If that's the case you probably need to use Workbooks.OpenText rather than Workbooks.Open.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top