Skip to main content
Inspiring
June 7, 2020
Answered

How to specify "Unconditional" in Visual Basic (or vbscript)?

  • June 7, 2020
  • 1 reply
  • 887 views

Can any one tell me how to specify "Unconditional" in Visual Basic (or vbscript)?

 

The code below is trying to set every text item to "Unconditional" text.

 

Dim myInDesign As InDesign.Application
myInDesign = CreateObject("InDesign.Application")
Dim myDocument As InDesign.Document
Dim myTextFrame As InDesign.TextFrame
Dim myText As InDesign.Text

 

For Each myDocument In myInDesign.Documents
For Each myTextFrame In myDocument.TextFrames
For Each myText In myTextFrame.Texts
myText.AppliedConditions = "[Unconditional]"  ' <----- This line
Next
Next
Next

This topic has been closed for replies.
Correct answer Kasyan Servetsky

Try to apply an empty array as you did in JS here:

Function main()
	Set myInDesign = CreateObject("InDesign.Application")
	Dim myEmptyArray()
	For Each myDocument In myInDesign.Documents
		For Each myTextFrame In myDocument.TextFrames
			For Each myText In myTextFrame.Texts
				myText.AppliedConditions = myEmptyArray
			Next
		Next
	Next
End Function

1 reply

Kasyan Servetsky
Kasyan ServetskyCorrect answer
Legend
June 7, 2020

Try to apply an empty array as you did in JS here:

Function main()
	Set myInDesign = CreateObject("InDesign.Application")
	Dim myEmptyArray()
	For Each myDocument In myInDesign.Documents
		For Each myTextFrame In myDocument.TextFrames
			For Each myText In myTextFrame.Texts
				myText.AppliedConditions = myEmptyArray
			Next
		Next
	Next
End Function
Tak OsatoAuthor
Inspiring
June 9, 2020

Thank you for your reply. Unfortunately, applying an empty array returns a COM exception error.

Below is the message. (The message itself is my translation. The original message is in Japanese.)

 

System.Runtime.InteropServices.COMException
HResult=0x0000770D
Message=The value of set property 'AppliedConditions' is invalid. The expected value is Array of Conditions, but value "nothing" was received.

Kasyan Servetsky
Legend
June 10, 2020

The code I posted works for me in InDesign 2020 (ver. 15.0.3) on Windows 10.