Copy link to clipboard
Copied
Goal: To have text placed from Word formatted in the paragraph styles I like. I receive the text from other authors and they are formatted with standard Word paragraph style formatting.
Two solutions:
How may I change the code in order to work in InDesign? The code should look for specific paragraph styles and change them or the style of the next paragraph.
Sub stilSkifte()
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"
Dim para As Paragraph
For Each para In ActiveDocument.Paragraphs 'søk gjennom hvert enkelt avsnitt i dokumentet
On Error Resume Next
'INGEN MELLOMROM og overskriftene
If para.Range.Style = "Ingen mellomrom" Then
para.Style = "Normal"
GoTo SisteLinje 'Gå til linja i koden som heter SisteLinje, = gå til neste avsnitt
End If
If para.Range.Style = "Overskrift 1" Then
para.Style = "Tittel-små"
GoTo SisteLinje 'Gå til linja i koden som heter SisteLinje, = gå til neste avsnitt
End If
If para.Range.Style = "Overskrift 2" Then
para.Style = "Ingress"
GoTo SisteLinje 'Gå til linja i koden som heter SisteLinje, = gå til neste avsnitt
End If
If para.Range.Style = "Overskrift 3" Then
para.Style = "mellomtittel"
GoTo SisteLinje 'Gå til linja i koden som heter SisteLinje, = gå til neste avsnitt
End If
'NORMAL til BYLINE
If para.Range.Style = "Ingress" Then
If para.Next.Style = "Normal" Then
para.Next.Style = "byline1"
End If
GoTo SisteLinje
End If
If para.Range.Style = "byline1" Then
If para.Next.Style = "Normal" Then
para.Next.Style = "byline2"
End If
GoTo SisteLinje
End If
'Hvis avsnittet er i NORMAL og det neste er...
If para.Range.Style = "Normal" Then
'...i NORMAL endres dette til NORMAL M INNRYKK
If para.Next.Style = "Normal" Then
para.Next.Style = "Normal med innrykk"
End If
GoTo SisteLinje
End If
SisteLinje: Next
End Sub
I apriciate any suggestions!
Copy link to clipboard
Copied
VBA only works on Windows, of course, not on a Mac. You are working in
Windows, right?
Copy link to clipboard
Copied
Yes, sorry!
I'm using:
Copy link to clipboard
Copied
... place/import it and somehow make sure that InDesign uses the styles I already defined in InDesign, not the way that style is defined in Word. I can't figure out how to do this.
When you're placing a word document, turn on the "Show Import Options" check box, or hold "Shift" and click "Open". Then in the "Microsoft word options" dialog box choose "Use InDesign style definition" for paragraph and character styles conflicts.
Copy link to clipboard
Copied
Thank you Kasyan, but it doesn't work as I expected it to. The InDesign style are somtimes overridden, sometimes not. It seems to have something to do with wether the Word-style is based on another Word-style or not. In addition I have my InDesign styles grouped, and when InDesign upon placing a text doesn't find the style on the top level, it imports the Word-style.
My solution:
Find more inspiration, events, and resources on the new Adobe Community
Explore Now