vbs help required [IDCS4]

Dear All,
I know this is not the right place to ask this question, but I know some one can help me here. I am having exposure on applescript and this is the first time when I am trying for vbscript.

---------------------Problem 1 (Joboption file is not get loaded in indesign application)--------------------------------------------

set idApp=CreateObject(“InDesign.Application.CS4”)
set myFileSysObject=CreateObject(“Scripting.FileSystemObject”)
idApp.Import InDesign.idExportPresetFormat.idPDFExportPresetsFormat, “C:\Test.joboptions”

-------------------Problem 2 (Copy all linked images [which are not linked from active indesign document path] to the path of active indesign document path and relink it). Please see my below apple script code----------------------------------------
tell application “InDesign CS4”
tell active document
set myFolderPath to get path
repeat with OLINK in (get links)
set LinkedPath to file path of OLINK
if LinkedPath is not (myFolderPath & name of OLINK) then
tell application “Finder” to set MovedFile to (move file LinkedPath to myFolderPath) as alias
relink (contents of OLINK) to MovedFile
update OLINK
end if
end repeat
end tell
end tell

The above code is working fine for AppleScript, and I want to convert it to vbscript, I know many of us can suggest/help me.


Reagrds,
Poo

Just a quick question but Adobe offers scripting in 3 languages. AppleScript for the Mac, VB for Windows & ExtendScript for cross-platform compatibility. As you appear to want the latter would it not be better to have a single ExtendScript solution over a solution for each platform?

Hi Mark,
You are correct and I am completely agree with you. These scripts was already developed and some changes are required in both the script. These scripts are well combined with the current in use process.

If I am going to convert this code in javascripts then I have to modify the call routing in web application then only I can embed it. This is already in plan to developed only one code for AS & VBS. Since I am running with a very short time and I have fixed all issues in apple script so that’s why I want to change in vbs as well.

Regards,
Poo

Some thing like this would have been a close translation to the above AppleScript. I don’t know what it is that you are doing but you may be able to supply to the document as text string and pass to the app’s doScript() method?

#target indesign

function main() {
if (app.documents.length == 0) {
alert(‘Please have an “Indesign” document before running this script.’);
return;
}
app.activate();
docRef = app.activeDocument;
with(docRef) {
var docFolder = filePath.fsName;
for (var i = 0; i < links.length; i++) {
if (links[i].status != LinkStatus.linkMissing) {
var tempFile = new File(docFolder + ‘/’ + links[i].name);
if (!tempFile.exists) {
links[i].copyLink(tempFile);
links[i].relink(tempFile);
} else {
alert(‘Link "’ + links[i].name + ‘"\n already exists in this location.’);
}
} else {
alert(‘Link "’ + links[i].name + ‘"\n was missing?’);
}
}
}
}

main();

Not sure if the syntax is allowed but here goes.

Dear Mark,
Many thanks for the code. But unfortunately I am unable to use it at present but yes it will be helpful once I will start migrating to javascript.

At present I am only looking if someone can help me in vbscript. I know may be this is not the right forum to ask but I am giving myself a chance. Some where I am doing mistake during loading joboptions.

Regards,
Poo

Dear All,
Below code is working fine when we are saving vbs file to script panel (script folder) of InDesign and running through Scripts windows.

set idApp=CreateObject(“InDesign.Application.CS4”)
set myFileSysObject=CreateObject(“Scripting.FileSystemObject”)
idApp.Import InDesign.idExportPresetFormat.idPDFExportPresetsFormat, “C:\Test.joboptions”)

But the same above code is not working when I am trying to run through command line or just by double clicking on it. Can any one help me why it is not working from command line.
Regards,
Poo

Somebody suggested me that it could be the reason of security of Windows, but I have tested with admin login on windows 7 & windows XP. But unfortunately I am getting the same error. I tried some other method as well like calling javascript but again it shows some error.
Below is the code I got from sdk folder.

Set myInDesign = CreateObject(“InDesign.Application.CS4”)
myJavaScript = “alert(”“First argument: “” + arguments[0] + “”\rSecond argument: “” + arguments[1]);”
myInDesign.DoScript myJavaScript, idScriptLanguage.idJavascript, Array(“Hello from DoScript”, “Your message here.”)
myVBScript = "msgbox arguments(1), vbOKOnly, "“First argument: “” & arguments(0)”
myInDesign.DoScript myVBScript, idScriptLanguage.idVisualBasic, Array(“Hello from DoScript”, “Your message here.”)

But it gives error for idScriptLanguage required at line 3 and char 1.

Regards,
Poo

Guys!!!
Fixed, please see below code:

Set idApp=CreateObject(“InDesign.Application.CS4”)
Set myFileSysObject=CreateObject(“Scripting.FileSystemObject”)
idApp.Import 1716745324, “D:\TestRajeev.joboptions”

Regards,
Poo

What code I need to change for copying the file. Below code is moving files but infact I am looking for copying file.

tell application "Finder" to set MovedFile to (move file LinkedPath to myFolderPath) as alias

Regards,
Poo