You are here: PSPad forum > English discussion forum > Open file through script

Open file through script

#1 Open file through script

Posted by: wimb | Date: 2012-12-05 10:41 | IP: IP Logged

Hi,

I would like a script that opens a file in PSPad using an open dialog with a fixed path.

Can this be done with pspad scripting commands?

I've tried it with a JScript but I get an error:
try
{
var objShell, objDialog, appDataPath;

objShell = new CreateObject("WScript.Shell");
appDataPath = objShell.SpecialFolders("AppData");
objDialog = new CreateObject("UserAccounts.CommonDialog");
objDialog.InitialDir = appDataPath;
objDialog.Filter = "All files (*.*)|*.*;Log files (*.txt)|*.txt;Log files (*.log)|*.log";
if (objDialog.ShowOpen())
{
echo(objDialog.FileName);
}
else
{
echo("cancelled");
}
}
catch (err)
{
echo(err.message);
}

But this failes at the line
objDialog = new CreateObject("UserAccounts.CommonDialog");
with the message "object doesn't support this property or method.

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR