• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

InDesign2014 goes into non-responding state when converting text variables to text

Explorer ,
Nov 27, 2022 Nov 27, 2022

Copy link to clipboard

Copied

Hi.

 

I have a VBA macro using variable.ConvertToText function to convert text variables to text.
This macro works well with different InDesign versions,
but now, when I run the macro for a document created in InDesign2014,
InDesign2014 goes into non-responding state.

 

In this document, there are tables, figures and the texts with two columns.
I have found that when InDesign2014 goes into non-responding state,
it's when the macro is converting a variable in a table.
This table has 1 row and 4 columns, and it is placed with a diagram in a text frame.
(The text frame contains a figure, and below the figure, the table with 1 row and 4 columns is placed.)
The text variable is set in a cell with no other text.

 

I have tried the following, but the problem is not solved.
1. Copy the document contents to a new document.
2. Export the document to idml, and reopen it in InDesign2014,then save as a Indesign document.

 

If I select the target variables from the TextVariables palette, and use the Convert To Text menu,
InDesign doesn't goes into non-responding state.

 

Because the InDesign version is specified, so I cannot use other versions of InDesign.

 

Please give me some advice.

TOPICS
Scripting

Views

299

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 28, 2022 Nov 28, 2022

Copy link to clipboard

Copied

Hi @erieru103 ,

you could select the text using a script command and also use the menu command for converting text variables to text programmatically.

However, I cannot help with VBA. With ExtendScript this is possible for sure.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

 

PS: Edited for clarification

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 28, 2022 Nov 28, 2022

Copy link to clipboard

Copied

With ExtendScript this is possible for sure.

But you don't know if it hangs InDesign 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 28, 2022 Nov 28, 2022

Copy link to clipboard

Copied

@erieru103 -- Can you show us your script?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 28, 2022 Nov 28, 2022

Copy link to clipboard

Copied

My code is the following.
Convert text variables to text only the character style or font applied them are the specified style.

Public Function ConvertToText(TgtIdDocs() As Object, idApp As Object)

  Dim var As Object
  Dim varName As String
  Dim i As Long, j As Long, k As Long
  
  
  For i = LBound(TgtIdDocs) To UBound(TgtIdDocs)
  
    Application.StatusBar = "Convert text variable to text in document " & i + 1 & "/" & UBound(TgtIdDocs) - LBound(TgtIdDocs) + 1 & " documents."
    
    If TgtIdDocs(i).TextVariables.Count > 0 Then
    
      For j = TgtIdDocs(i).TextVariables.Count To 1 Step -1
      
        Set var = TgtIdDocs(i).TextVariables.Item(j)
        varName = var.Name
        
        If IsTgtCharStyleVar(varName) = True Or IsTgtFontVar(varName) = True Then
        
          var.ConvertToText
          var.Delete
        
        End If
        
      Next
    
    End If
    
  Next
  
  Set var = Nothing
  
End Function

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2022 Nov 30, 2022

Copy link to clipboard

Copied

Not much of a VBA expert, but I suspect that if you are deleting the var after converting, you are throwing off your for loop. This commonly happens in JSX too when removing items from an array. Typically, to work around this, we iterate backward from the total length of the array down to 0. Edit: Nevermind, it looks like  you're doing that. But I suspect the hang has something to do with it; what if you remove the Delete call. Does it still hang? 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 30, 2022 Nov 30, 2022

Copy link to clipboard

Copied

Hi, brianp311

 

My VBA code iterates backward from the total length of the array down to 0.

I have tried to remove the Delete call and run the macro,  then,  InDesign2014 don't hang!!!!

But, the text variable in the table doesn't be converted to text.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 30, 2022 Nov 30, 2022

Copy link to clipboard

Copied

Sorry.
My code doesn't iterates backward from the total length of the array down to 0, it's down to 1.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 02, 2022 Dec 02, 2022

Copy link to clipboard

Copied

It seems that InDesign2014 hangs is because the text variable doesn't be convert to text, and it is deleted in that state.

 

I changed the code to convert to text as the following.

(1)Get text variable

(2)Get AssociatedInstances of the text variable

(3)Convert to text from instances

(4)Delete the text variable

 

If IsTgtCharStyleVar(varName) = True Or IsTgtFontVar(varName) = True Then    
  ' var.ConvertToText
  If UBound(var.AssociatedInstances) - LBound(var.AssociatedInstances) + 1 > 0 Then     
      For k = UBound(var.AssociatedInstances) To LBound(var.AssociatedInstances) Step -1        
          Set varInst = var.AssociatedInstances(k)
          varInst.ConvertToText    
      Next  
  End If
  var.Delete
End if

 

 This works well. InDesign2014 don't hang and no text variable doesn't be converted to text.

 

I don't know why I can convert to text from variable instances but I can't do it from text variable itself.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 05, 2022 Dec 05, 2022

Copy link to clipboard

Copied

@erieru103 says: "I don't know why I can convert to text from variable instances but I can't do it from text variable itself."

 

Hi @erieru103 ,

had no time to test this myself yet.

Could be a bug in InDesign CC 2014.

What exact version of InDesign CC 2014 are you testing?

 

Can you tell what versions of InDesign will work for you?

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 05, 2022 Dec 05, 2022

Copy link to clipboard

Copied

LATEST

The version of InDesign2014 is 10.2.0.69 x64 build.

In this version, I can convert to text from variable instances but not text variable itself.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines