Copy link to clipboard
Copied
Hello!
I am very new to Adobe InDesign. I looked at the tutorial for creating and generating scripts. I created a simple script. It opens a new InDesign document and writes Hello World. It's the script that came from the tutorial.
However, it only works when I am outside of Adobe InDesign. I place the script on my desktop and double click on it, it works fine. But if I'm in Adobe InDesign and select Windows -> Utilities -> Script and select the same script name, all I hear is a beep and nothing happens. The same for any preloaded scripts.
I am using Adobe InDesign 2021 and the script I am using is vbscript. Any suggestion on if this is a permission issue or am I missing something.
Copy link to clipboard
Copied
Hello,
If you would post the code you're trying to run from Indesign it would be usefull for us on the fourm to try and help you.
Regards,
Mike
Copy link to clipboard
Copied
Here is the code: I took it from the script tutorial.
--------------- code -------------------------------------------------
Set myInDesign = CreateObject("InDesign.Application")
Set myDocument = myInDesign.Documents.Add
Set myTextFrame = myDocument.Pages.Item(1).TextFrames.Add
myTextFrame.GeometricBounds = Array("6p", "6p", "24p", "24p")
myTextFrame.Contents = "Hello World!"
--------------- code -------------------------------------------------
I works on my desktop but if I copy it to the C:\Users\myUserId\AppData\Roaming\Adobe\InDesign\Version 16.0\en_US\Scripts\Scripts Panel where I can access it in Adobe InDesign through Windows -> Utilities -> Scripts and select it that way, it wont run. Just beeps at me.
Copy link to clipboard
Copied
Hello,
I normally work on a Mac not a PC..........So what I did was, I copied the code you posted and pasted it in to Visual Studio Code and saved it as XXX.vbs,
Then I loaded it in Indesign on a PC I have access to using the following method and the script worked for me.
"From the Scripts panel select on the "User" folder, choose Reveal in Windows Explorer, Inside the folder that opens there is a folder called Scripts Panel. Put your scripts inside that folder."
Maybe you just need to ad the .vbs extension to the script file.
Regards,
Mike
Copy link to clipboard
Copied
Hi Mike,
thank you very much for this question.
I never tested the pre-installed vbs scripts that come with InDesign 16.1 on Windows 10.
What should I say, they did not work at all on my machine. Nothing happened with a double-click on a vbs script file showing in my Application > Samples > VBScript folder of the Scripts panel in InDesign. I have no idea why they do not work at all. No error message. Nothing, but a sound.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Hi together,
no solution on my side, but after a test with this ExtendScript (JavaScript) code below I have an error number and an error message. Script run from the ESTK on my German Windows 10 machine, target is the German version of InDesign 16.1.0.20.
var visualBasicCodeString =
'''
Set myInDesign = CreateObject("InDesign.Application")
Set myDocument = myInDesign.Documents.Add
Set myTextFrame = myDocument.Pages.Item(1).TextFrames.Add
myTextFrame.GeometricBounds = Array("6p", "6p", "24p", "24p")
myTextFrame.Contents = "Hello World!"
''';
try{
app.doScript( visualBasicCodeString , ScriptLanguage.VISUAL_BASIC );
}catch(e)
{
$.writeln( "Error No: " +e.number +", Error message: "+ e.message );
}
/*
RESULT:
Error: 104705 Adobe InDesign 2021 Type Library kann nicht geladen werden (Version 1.0).
*/
Result:
Error No: 104705, Error message: Adobe InDesign 2021 Type Library kann nicht geladen werden (Version 1.0).
( Cannot load Adobe InDesign 2021 Type Library (Version 1.0) )
The file Resources for Visual Basic.tlb is in the appropriate folder:
User > UserName > AppData > Local > Adobe > InDesign > Version 16.0 > de_DE > Caches > Scripting Support > 16.1
Perhaps someone can identify the issue.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
FWIW:
This should be solved with the next update with InDesign version 16.2. See:
Type library is not automatically created by CC2020 installation. Error 104705: Unable to load Adobe InDesign Type Library (Version 1.0)
Andreas, August 04, 2020
https://indesign.uservoice.com/forums/601180/suggestions/41072476
Fixed issues in InDesign
InDesign 2021 (version 16.2)
Scripting
[Win only] VB Script can be executed only after InDesign is launched in Admin mode at least once.
https://helpx.adobe.com/indesign/kb/fixed-issues.html
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
To Mike5E65,
because you are new to InDesign, perhaps also new to scripting, I would suggest to work around the whole problem and start scripting using a different language: ExtendScript (JavaScript).
ExtendScript is widely used, well documented and supported with InDesign on Mac OS and Windows as well.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Thanks for the info. I did get it to work in javascript. I was trying vbscript because we have macros in vba that is used for Microsoft Word that will need to be maintain. But I will continue to look javascript. Are there readily available tutorials for javascript and InDesign. All I'm seeing is for CS6 and nothing newer.
Thanks,
Mike
Copy link to clipboard
Copied
Hi Mike,
FYI, Adobe hasn't published any new tutorials or javascript samples/documentation since CS6.
The link below doesn't contain a samples but it's a necessary reference tool........
Here's the link to the InDesign API for InDesign 2021 (16.0)
https://www.indesignjs.de/extendscriptAPI/indesign-latest/index.html#$.html
Regards,
Mike