- AuthorPosts
- March 2, 2009 at 4:24 pm #7008shxParticipant
Using a macro I am copy the currently open file to a another file with the same name and a different extension.
The copy works and the file is copied.
However, when I execute
“editor.OpenFile pxbfilename ” it fails and says it can not execute the command.Why?
The Code
Set fso = CreateObject( “Scripting.FileSystemObject” )
thefullfilename = document.FullName
pxbfilename = Replace(thefullfilename,”.pub”,”.pxb” )
fso.CopyFile document.FullName, pxbfilename
editor.OpenFile pxbfilenameSteven
March 2, 2009 at 5:49 pm #7009Yutaka EmuraKeymastershx wrote:
Using a macro I am copy the currently open file to a another file with the same name and a different extension.
The copy works and the file is copied.
However, when I execute
“editor.OpenFile pxbfilename ” it fails and says it can not execute the command.Why?
The Code
Set fso = CreateObject( “Scripting.FileSystemObject” )
thefullfilename = document.FullName
pxbfilename = Replace(thefullfilename,”.pub”,”.pxb” )
fso.CopyFile document.FullName, pxbfilename
editor.OpenFile pxbfilenameSteven
It should work, but may be you should insert “Sleep” method between CopyFile and OpenFile. Can you try adding
Sleep 1000
before OpenFile method?
March 2, 2009 at 7:15 pm #7011shxParticipantThanks for your help.
Actually the problem was that the macro was triggered by an open file event.
If I run it manually it works.
Is this the way it is suppose to work. That if it triggered by an open file event it can not open a file in the current tab which would then close the original file?
March 2, 2009 at 8:56 pm #7012Yutaka EmuraKeymastershx wrote:
Thanks for your help.Actually the problem was that the macro was triggered by an open file event.
If I run it manually it works.
Is this the way it is suppose to work. That if it triggered by an open file event it can not open a file in the current tab which would then close the original file?
It all depends on how EmEditor opens the file, and how you open the file with your macro. How EmEditor opens the file depends on your settings (Configuration Properties > File tab in Changed by Another Program drop-down list box). Also, if you open a large file, EmEditor might open in asynchronous mode (you can set the threshold in the Customize > Advanced tab). I hope this information helps.
March 2, 2009 at 9:36 pm #7013shxParticipantO.K
Steven
June 26, 2015 at 1:08 am #20212StefanParticipantSame for me. v15.1.5, 32-bit portable.
editor.OpenFile( strFile )
didn’t work but give errorif I call that command
from within a script
with enabled ‘File Opened’ Event.
Dummy code f.ex.:OnFileOpenedEvent.jsee
if(strFileExt==”XML”)
editor.OpenFile( strOtherExistentFile )
Please assist. - AuthorPosts
- You must be logged in to reply to this topic.