Trying to set up a macro for EmEditor to execute the following steps that I could otherwise do manually.
I'm using: EmEditor Professional (64-bit) version 22.4.1. Windows 10 operating system.
I tried recording, that didnt seem to work.
Then I tried variations of this snippet suggested as answer but error provided was specificed file does not exist.
editor.WriteProfileInt( eeRegCommon, "", "DefaultBytesTo", 1000 ); // open to 1000 bytes
editor.RefreshCommonSettings();
editor.OpenFile( "D:\\Test\\Input.txt", 0, eeOpenDetectUnicode | eeOpenDetectUTF8 );
editor.WriteProfileInt( eeRegCommon, "", "DefaultBytesTo", 0 ); // open to unlimited
editor.RefreshCommonSettings();
editor.ExecuteCommandByID(4323); // Clear All Bookmarks in This Document
editor.ExecuteCommandByID(4588); // Invert Bookmarks in This Document
editor.ExecuteCommandByID(4590); // Extract Bookmarked Lines in This Document to New File
document.Save( "D:\\Test\\TestMacro.txt" );
How is this macro set up to achieve these steps?
After editing my file path to "input" instead of "input.txt" error was resolved.
I wrote a macro to open a file E:\Test\Input.txt
to 1000 bytes, and save it as E:\Test\TestMacro.txt
.
Notes:
To
bytes in the File
page of the Customize
dialog box, but this macro will change this only while opening the file, and revert it to default automatically when done.Save Opened Portion As
, but you can set bookmarks to all lines, extract bookmarked lines to a new file, and then save the new file as TestMacro.txt
.editor.WriteProfileInt( eeRegCommon, "", "DefaultBytesTo", 1000 ); // open to 1000 bytes
editor.RefreshCommonSettings();
editor.OpenFile( "E:\\Test\\Input.txt", 0, eeOpenDetectUnicode | eeOpenDetectUTF8 );
editor.WriteProfileInt( eeRegCommon, "", "DefaultBytesTo", 0 ); // open to unlimited
editor.RefreshCommonSettings();
editor.ExecuteCommandByID(4323); // Clear All Bookmarks in This Document
editor.ExecuteCommandByID(4588); // Invert Bookmarks in This Document
editor.ExecuteCommandByID(4590); // Extract Bookmarked Lines in This Document to New File
document.Save( "E:\\Test\\TestMacro.txt" );