Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #7008
    shx
    Participant

    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 pxbfilename

    Steven

    #7009
    Yutaka Emura
    Keymaster

    shx 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 pxbfilename

    Steven

    It should work, but may be you should insert “Sleep” method between CopyFile and OpenFile. Can you try adding


    Sleep 1000

    before OpenFile method?

    #7011
    shx
    Participant

    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?

    #7012
    Yutaka Emura
    Keymaster

    shx 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.

    #7013
    shx
    Participant

    O.K

    Steven

    #20212
    Stefan
    Participant

    Same for me. v15.1.5, 32-bit portable.

    editor.OpenFile( strFile )
    didn’t work but give error

    if 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.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.