Tagged: vertical selection Viewing 6 posts - 1 through 6 (of 6 total) Author Posts August 13, 2025 at 6:42 pm #30387 Waheed AlsayerParticipant Hi, Why does this macro gives an error at line 2 document.selection.StartOfDocument editor.ExecuteCommandByID 4472 ' no csv editor.ExecuteCommandByID 3889 ' Vertical Selection document.selection.Text = document.FileName document.selection.Collapse() August 13, 2025 at 7:21 pm #30388 Waheed AlsayerParticipant Eventhough I would like to know why I got this error, I found another method of doing the same. I used Find and Replace in files, Find: ^ Replace: $(Filename)| And it worked. August 14, 2025 at 4:56 am #30389 Patrick CParticipant Its document.FullName rather than document.FileName. file:///C:/ProgramData/Emurasoft/EmEditor/Help/en/macro/document/document_fullname.html August 14, 2025 at 9:00 am #30391 StefanParticipant That brings still the error on Line 2: “;” awaited But adding an explicit >>#language =”VBScript”<< on the first line, let the script work. #language ="VBScript" document.selection.StartOfDocument editor.ExecuteCommandByID 4472 ' no csv editor.ExecuteCommandByID 3889 ' Vertical Selection document.selection.Text = document.FullName + " " document.selection.Collapse() HTH? August 14, 2025 at 10:36 am #30393 Waheed AlsayerParticipant Thanks, Ok, I’ll add the #language but I don’t want the full path, just the file name without the extension. August 15, 2025 at 3:21 am #30394 Patrick CParticipant just the file name without the extension To my knowledge EmEditor has not got a document name without extension property. In JavaScript I’d do the following: let bareName = ""; let iLastIdx = document.Name.lastIndexOf("."); if (iLastIdx > 0) { bareName = document.Name.substring(0, iLastIdx); } OutputBar.writeln("bareName = «" + bareName + "»"); Author Posts Viewing 6 posts - 1 through 6 (of 6 total) The forum ‘Questions and Answers about Macros’ is closed to new topics and replies.