open excel file using wildcard

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jmcall10
Posts: 31
Joined: 25 Jan 2016, 21:27

open excel file using wildcard

18 Sep 2018, 11:39

Hi All,

I currently have a script that opens an excel using the following format:

run \\Server001\Documents\MAINFILE.xlsx

However, the file now has random text added to the filename (I cannot control the naming of the file).
For example the filename might be "MAINFILE ABC.xlsx" one moment and then "MAINFILE A1B2XY57.xlsx" the next.

Is it possible to open an excel using a wildcard so that "MAINFILE *.xlsx" or something similar would work?

Kind Regards,

jmcall10
awel20
Posts: 211
Joined: 19 Mar 2018, 14:09

Re: open excel file using wildcard

18 Sep 2018, 12:25

Code: Select all

Loop, Files, \\Server001\Documents\MAINFILE*.xlsx
{
    MsgBox % A_LoopFileFullPath
}
User avatar
TheDewd
Posts: 1510
Joined: 19 Dec 2013, 11:16
Location: USA

Re: open excel file using wildcard

18 Sep 2018, 12:26

Looks like awel20 finished before me, but here's what I was going to suggest:

Code: Select all

#SingleInstance, Force

Loop, Files, \\Server001\Documents\*.xlsx, F
{
	If (InStr(A_LoopFileLongPath, "MAINFILE")) {
		Run, % A_LoopFileLongPath
		Break
	}
}
jmcall10
Posts: 31
Joined: 25 Jan 2016, 21:27

Re: open excel file using wildcard

18 Sep 2018, 12:34

Excellent! I shall give these a go and feedback.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, arcylix, drani, Google [Bot], Nerafius, Rohwedder and 220 guests