• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 141
  • Last Modified:

Need to open a .csv file from code without assuming the use of Excel

Hi,

I need to be able to open a .csv file from code.

In fact, what exactly needs to happen is that the the .csv file is opened in such a way as to mimic the double-clicking of the file from Windows Explorer when it may by default open Excel if it is on the PC or otherwise Notepad etc...... You see, many of the machines on which this software is running may not contain Excel, and even if they do, the user may expect .csv files to open in another app to which they associate .csv files.

This is a return to an old app out in the field using VB6. Is what I'm trying to do possible?

All and any help appreciated

Thanks
Iain
0
iaing1000
Asked:
iaing1000
1 Solution
 
DarkoLordCommented:
If I understand you correctly, you just want to open a file in the associated application? Try the ShellExecute API:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Form_Load()
    ShellExecute 0, "Open", "c:\file.csv", 0, 0, 1
End Sub

0
 
iaing1000Author Commented:
Hi,

Yes, that seems to work perfectly.

Thanks
Iain
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now