Note that there are some explanatory texts on larger screens.

plurals
  1. POWorkbooks.OpenText doesn't take 'fieldinfo' parameter
    text
    copied!<p>The following code demonstrates the problem which is stated in questions title.</p> <p>Copy &amp; paste it in a new Microsoft Excel 2003 workbook. </p> <pre><code>Sub mytest() mypath = Application.GetSaveAsFilename() Workbooks.OpenText Filename:=mypath, DataType:=xlDelimited, _ TextQualifier:=xlTextQualifierDoubleQuote, _ semicolon:=True, _ fieldinfo:=Array(Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 2)), _ Local:=True End Sub </code></pre> <p>Execute the code. It will ask for an input file where you should use this semicolon-seperated <a href="http://ge.tt/2q7vwYE/v/0" rel="nofollow noreferrer">test.csv</a>. It creates a new workbook and imports all the data from test.csv to sheet1.</p> <p>The picture below shows the result<br> <img src="https://i.stack.imgur.com/TeYBd.jpg" alt="enter image description here"></p> <p>But It should have shown a result like this<br> <img src="https://i.stack.imgur.com/8M4bZ.jpg" alt="enter image description here"></p> <hr> <p><code>fieldinfo:=Array(Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 2))</code><br> states that Excel should treat all imported data as text. Unfortunately it doesn't.</p> <ul> <li>The two-dimensional array: <a href="http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.opentext%28v=vs.80%29.aspx?cs-save-lang=1&amp;cs-lang=vb#code-snippet-2" rel="nofollow noreferrer">first number is the column number, second number stands for data type</a> where 2 stands for text</li> <li>I have to use the 'local'-parameter because I'm on a localized OS with a localized Office 2003</li> <li>The operating system is irrelevant since it happens on Windows XP and on Windows 7</li> </ul> <p>Can someone show me how to use opentext and fieldinfo in the correct way?</p> <p>I already know the work-around with QueryTables.Add(Connection[...].<br> But thats not a solution for my case.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload