acantor Posted August 10, 2021 Report Share Posted August 10, 2021 I have text files on my computer from a bygone era. Virtually all of the filenames have obsolete extensions such as... .mss .spr .wp4 .spm Some of my files don't even have extensions. (My recollection is that filename extensions were optional during the MS-DOS age.) Modern programs such as Word and WordPerfect don't recognize antediluvian file types and/or files without extensions. Ditto for basic text editors such as WordPad or NotePad. Every time I want to view my old files, I'm forced to do a song-and-a-dance, with far too many steps. The challenge is to use Macro Express to create one hotkey macro for Windows 10 File Explorer. With any file selected, press the hotkey. The selected file opens in WordPad -- or in another program, if you prefer. The macro should open any file with any extension. I experimented with different methods before I settled on a script that works reliably. So I'm so curious what other people come up with. For bonus "points," find a solution that keeps focus on the most recently opened file in File Explorer. In other words, let's say you open the first file in a folder by pressing the hotkey. Close the file. Then press down arrow to select the second file in the folder and press the hotkey to open it. Quote Link to comment Share on other sites More sharing options...
Cory Posted August 10, 2021 Report Share Posted August 10, 2021 You don't need a macro, just set the file extension association to whatever app you want to open it with. Settings > Apps > Default Apps > Choose default apps by file type. Or you can double click the file, then select yoru app and check the box to "Always use this app..." Quote Link to comment Share on other sites More sharing options...
acantor Posted August 10, 2021 Author Report Share Posted August 10, 2021 I wouldn't have needed a macro had I taken the time to associate hundreds of file extensions. The files were created when one could choose almost any combination of letters, numbers, and symbols for the three-letter extension, including none. The macro circumvents the need to set up associations manually, or on-the-fly. Check out these extensions in a folder of files from 1993... Although I made the macro to handle old files, I find it a handy way to open "modern" file types that I occasionally but rarely access, e.g., .css .html .ahk Quote Link to comment Share on other sites More sharing options...
rberq Posted August 10, 2021 Report Share Posted August 10, 2021 First thing I would try is: 1) Right-click and rename the file appending whatever extension is desired: filename.ext becomes filename.ext.xyz 2) Double-click the name or ENTER to open it with the xyz-associated application; or launch the application via the macro 3) Use a second macro to rename it back to the original after editing or whatever you want to do with the file Might run into trouble with this, there may well be some hitch I'm not thinking of. If all you want to do is look at the file, and don't plan to change and save it, the macro could copy it to a Temp folder/name with the xyz extension, and open it there. Quote Link to comment Share on other sites More sharing options...
acantor Posted August 11, 2021 Author Report Share Posted August 11, 2021 1 hour ago, rberq said: If all you want to do is look at the file, and don't plan to change and save it, the macro could copy it to a Temp folder/name with the xyz extension, and open it there. Copying the file and opening the copy is not what I did, but it's worth considering. Normally I open an old file, read it and/or copy something from it, and then exit without saving. I don't want to modify my old files. So maybe this kind of logic? 1. Copy the selected file. 2. Paste the copy in a temporary folder. 3. Rename the copied file: append .txt or .rtf (or whatever) to the end of the file name. 4. Open the renamed file. Quote Link to comment Share on other sites More sharing options...
acantor Posted August 13, 2021 Author Report Share Posted August 13, 2021 Here's my solution. 1. Open your "SendTo" folder. How? Press Windows + R. This will bring up the "Run" dialog box. In the "Open" field, type: shell:SendTo Press Enter, or click the "OK" button. File Explorer will open the SendTo folder for your Windows account. 2. Ensure the SendTo folder includes a shortcut to WordPad. If a shortcut to WordPad does not exist, navigate to this folder: C:\Program Files\Windows NT\Accessories\ Scroll down to "wordpad.exe," make a shortcut, and move the shortcut to the SendTo folder. Rename the shortcut "WordPad". Suggestion: If there are other objects in the SendTo folder that start with the letter "W," rename them. 3. Create a new Macro Express script triggered by your hotkey of choice. Set the scope to Window/Program. Specify EXPLORER.EXE as the program. 4. Insert this code in the Script tab: Text Type (Simulate Keystrokes): <APP> Delay: 100 milliseconds Text Type (Simulate Keystrokes): n Delay: 100 milliseconds Text Type (Simulate Keystrokes): w <TEXT TYPE Action="0" Text="<APP>"/> <DELAY Flags="\x02" Time="100"/> <TEXT TYPE Action="0" Text="n"/> <DELAY Flags="\x02" Time="100"/> <TEXT TYPE Action="0" Text="w"/> What it does: 1. Press the hotkey to open the context menu for the selected object; 2. Choose "Send to" from the context menu. 3. Choose "WordPad" from the submenu. Quote Link to comment Share on other sites More sharing options...
rberq Posted August 13, 2021 Report Share Posted August 13, 2021 Simple and neat and clean! Quote Link to comment Share on other sites More sharing options...
acantor Posted August 13, 2021 Author Report Share Posted August 13, 2021 Thank you, rberq! Yet the approach you mentioned -- open a copy of the file rather than the original -- has merit, and I might try it. I can tell you about an approach that I thought was promising. But I couldn't get it to work: 1. Extract the path to the selected file from the Address line: %Path% 2. Extract the name of the selected file through its properties: %FileName% 3. Use Macro Express to launch WordPad, with "%Path%\%FileName%" as its parameter. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.