Tagged: vertical selection
- AuthorPosts
- August 13, 2025 at 6:42 pm #30387
Waheed Alsayer
ParticipantHi,
Why does this macro gives an error at line 2document.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 #30388Waheed Alsayer
ParticipantEventhough 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 #30389Patrick C
ParticipantIts
document.FullName
rather thandocument.FileName
.
file:///C:/ProgramData/Emurasoft/EmEditor/Help/en/macro/document/document_fullname.htmlAugust 14, 2025 at 9:00 am #30391Stefan
ParticipantThat 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 #30393Waheed Alsayer
ParticipantThanks,
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 #30394Patrick C
Participantjust 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 + "»");
- AuthorPosts
- You must be logged in to reply to this topic.