Hi

I am using VB code created by recording a macro. I need to import as text, the content of a CSV file into a worksheet. The code I used is below.

When I first ran the code, I got an error (Run-time error 5, Invalid procedure call or argument).

I searched the internet and found a few people saying that the code generated includes the line '.commandtype = 0', but this is allegedly a Microsoft bug as there is no command 0 and I should just omit this line. I commented it out and it worked - for a while.

Now, a few hours later, it is coming up with the same error. I have excluded the 'commandtype =0' line and included it, but get the same error. I have single-stepped the code so I know this is where it is stopping.

Can anyone help with this, or even provide better code please? I am developing this in Excel 2013/365, but it will be used on mix of Excel 2007, 2010 and 2013 PCs.

By the way, I have included all of the code which also includes a prompt to the user asking if they want to import the data, and puts a time stamp on a worksheet with the date/time the source data file was created. I have included this just in case there is an issue within that code.

Please Login or Register  to view this content.