Jump to content
Sign in to follow this  

Open file with

Recommended Posts


I am using this code to open a file

Case $msg = $EditSent


$SentFile = FileOpenDialog("Select a File", @ScriptDir & "\DataFiles\Mailed", "Files (*.csv)", 1)

If $SentFile = "" Then ExitLoop

ShellExecute($SentFile, "", @ScriptDir & "\DataFiles\Mailed\", "edit")


The file is saved in .csv Windows Format (created in Excel). The file is associated with Excel (file properties). However my code always opens the file

using Notebook when it should be opened using Excel.

Why is it so?

Help is always appreciated



Sorry I have answered my own question in ShellExecute($SentFile, "", @ScriptDir & "\DataFiles\Mailed\", "edit")

you change "edit" to "open" the code therefore should read

ShellExecute($SentFile, "", @ScriptDir & "\DataFiles\Mailed\", "open")



Edited by anixon

Share this post

Link to post
Share on other sites

Normally if the file is associated with excel : ShellExecute("filename.csv") should work if not then you have to look at the registry. simply run regedit.exe, scroll in the "HKEY_CLASSES_ROOT" Key and look for sub ".csv" inside it another sub key must be called "Shell" and then "open" and then "command" key. if it is something like "Notepad.exe %1" then you need to modify this entry . sorry if i didn't explain it very well.

Share this post

Link to post
Share on other sites

A workaround is to Execute Excel with the filepath as parameter

ShellExecute(PathToExcel.exe PathToFile)

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this