07-25-2018 11:47 AM - edited 07-25-2018 11:49 AM
@aputman wrote:
You want to use the Workbooks.OpenText method.
To elaborate....wire a True constant into the Tab field and you're done. The fieldInfo field can be used to specify the format of the imported data. This is how it would be done in VB
Workbooks.OpenText Filename:="C:\Users\aputman\Desktop\Text file.txt", _ Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _ Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 2), _ Array(2, 2), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _ Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15 _ , 3)), TrailingMinusNumbers:=False
And in Labview....
The first column in the array corresponds to the imported column number in Excel. The second column corresponds to the field type (1 = General, 2 = Text, 3 thru 8 = Date formats, 9 = Do Not Import).
07-26-2018 04:35 AM
@alexderjuengere
Thanks for your responde, I'll give it a try right now ! Im using LV2014
07-26-2018 07:38 AM
@ haamza09:
attached as 2014
---------
@ aputman: this looks really straight forward, if task is "convert .txt to .xlsx"
I've rebuild this snippet from your screenshot, finally none of the active X nodes throws an error anymore.
so, this is supposed to open the .txt file directly in Excel -
now we need to figure out how to close EXCEL and save the imported .txt as .xlsx to disk.
Could you guide us which activeX properties or methods to use?
07-26-2018 08:44 AM
@alexderjuengere wrote:
so, this is supposed to open the .txt file directly in Excel -
now we need to figure out how to close EXCEL and save the imported .txt as .xlsx to disk.
Could you guide us which activeX properties or methods to use?
The OpenText method opens the file and adds it to the workbooks collection. You'll need to index the workbooks collection to grab this particular workbook and call the Save method. The save method asks for a Filename and FileFormat. XLSX fileformat is the number 51.
07-27-2018 04:52 AM
@aputman: thank you!
the "Excel Get ActiveX References VI " requires the Report Generation Toolkit, which became a part of the Professional Development System, so I'm fine with this.
It's a convenient way to automatically to create the ActiveX "Excel._Application" reference, which I have done manually
08-01-2018 07:57 AM - edited 08-01-2018 07:58 AM
Hi haamza09,
I'd like to offer help exploring an alternative path to the one you've requested. If your end goal is to explore your data, analyze it and make reports out of it, then perhaps you'd be better served with NI's DIAdem product instead of Excel. You may be operating under company requirements you can't influence such that you don't have that flexibility, but I thought I'd float the idea. What I'd be happy to do is build you a quick DataPlugin that would make your *.txt files a native file format for DIAdem, such that you could drag data files into DIAdem interactively to load them. From there graphing would also be simple drag&drop and analysis would be dialog-based interactive selections.
As an aside, have you tried changing the file extension of your *.txt file to *.xls? You have to click "yes" in the initial pop-up dialog, but otherwise double-clicking your ASCII file named with an *.xls extension loads the file into Excel exactly as you indicated you wanted.
Let me know if you're interested in exploring DIAdem,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
08-02-2018 02:47 AM
Hi @aputman & @alexderjuengere
Thanks for your help !!
The solution you @aputman suggested to me seems to be the one I was looking for !! Hence, I'm running on Labview 2014, so I cant drag the png to the diagramme, can you please send me the VI pleaase ??
08-02-2018 09:09 AM
Haamza,
I intentionally did not post the image with the code embedded. Nor did I save it to disk, which means you'll need to recreate it on your own. It's not difficult to recreate and you may learn something in the process.