+ Reply to Thread
Results 1 to 2 of 2

MSWord macro hangs during execution

  1. #1
    Registered User
    Join Date
    10-28-2020
    Location
    Lipa, Batangas
    MS-Off Ver
    2010
    Posts
    1

    MSWord macro hangs during execution

    Hello guys!

    I am currently doing a macro on ms word where I need to automatically update the document properties in the header section of a 900 pager document. I have created the code below (with the help of google of course :D), it is already working but but unfortunately, it hangs at the middle of the document. Can anyone help me on why this occurs?

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    Dim docMultiple As Document
    Set docMultiple = ActiveDocument
    Dim a As Integer
    a = docMultiple.ComputeStatistics(wdStatisticPages)
    If a = ActiveDocument.Range.Find.Parent.Information(wdActiveEndPageNumber) Then

    For i = 1 To a
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    ActiveWindow.ActivePane.View.Zoom.PageFit = wdPageFitFullPage
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    Selection.WholeStory
    Selection.Fields.Update
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    Selection.MoveDown Unit:=wdScreen, Count:=1
    Next
    Else
    Exit Sub
    End If

    End Sub

  2. #2
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: MSWord macro hangs during execution

    does the following code equate to 900?

    Please Login or Register  to view this content.
    and what line does it hang on/ how do you know? have you stepped through line by line during the hang?

    and are you aware that, because VBA is not the best language in the world (not even close) and the VBE and engine is not powerful whatsoever, whenever you have a long routine that requires minutes to run, you WILL see it, what you call, *hang*. and it will freeze up and the screen will go white if you try to transact. but keep in mind that the code is still running and nothing is wrong. I've never run into an issue like that where the stack actually did overflow and thus everything broke. I seriously doubt it would happen for you either.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Code Execution Hangs When Run by the Task Scheduler
    By dflak in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-27-2019, 10:21 AM
  2. Converting MSWord Title Case macro to work in Excel
    By jerrydiaz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-12-2014, 11:50 AM
  3. Program execution hangs on deleting rows shown in an AutoFilter
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-22-2013, 10:12 PM
  4. Macro hangs up
    By LonnieP in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-08-2010, 07:00 PM
  5. MSword hangs whenever i copy anything on it
    By Reema in forum Word Formatting & General
    Replies: 2
    Last Post: 04-20-2009, 02:35 PM
  6. [SOLVED] Macro target to MsWord
    By Param in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-20-2006, 11:25 AM
  7. re: vlookup in a msword macro returning an error
    By HeatherO in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-06-2005, 03:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1