Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8922603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:53:01+00:00 2026-06-15T06:53:01+00:00

I need a script which iterates through a word document and changes the style

  • 0

I need a script which iterates through a word document and changes the style of paragraphs following a Headline style or an Image to a custom style without first line indent.

How do I loop through the paragraphs/headers/items in a word document? And how do I get the style? And how do I set the style afterwards?

The Goal is simple: I want the first line of a paragraph be indented, but not if the paragraph is following a Header line or image. And since this is a large document and I get those quite often I’d like some Kind of Automation and not try to do this by Hand.
So I’d like to write a script which is iterating through the paragraphs and changes the style from “paragraph” to “paragraph without indent” when it is after a header style or image.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:53:03+00:00Added an answer on June 15, 2026 at 6:53 am

    Here is some basic code to get you started here. Unfortunately, the Paragraph.Style parameter doesn’t distinguish between text and images, but you can check and see if a Paragraph.Range object has any InlineShapes, which are images.

    Sub indentParas()
        Dim doc As Document
        Set doc = ActiveDocument
        Dim para As Word.Paragraph
        Dim i As Boolean
        i = False
        For Each para In doc.Paragraphs
    
            If i = False Then
                para.IndentCharWidth 4
            End If
    
            If para.Range.InlineShapes.Count > 0 Then
                i = True
            ElseIf Left(para.Style, 7) = "Heading" Then
                i = True
            Else
                i = False
            End If
        Next
    End Sub
    

    Note: this is tested in Word 2010.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a script which iterates through a couple pages of a third party
I need a script which makes rounded transparent corners on supplied image. I've found
I have a bash script which need to execute some php scripts and to
I need to write a script which will post username and password onto a
I need to modify an existing script which uses SED to search and replace
I have a VBS script which I need to run on a monthly basis
I need to write a php script which is called by a setInterval( ajaxrequest('ftp.php',
I really need some quick tips here. I've got this VBScript script which sends
I am right now running a bash script in which i need to change
I need to write a script in Matlab, which will read some data from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.