View Single Post
 
Old 10-23-2018, 06:25 AM
Wojix Wojix is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Apr 2018
Posts: 8
Wojix is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
You didn't supply the macro called Create_Reset_Variables ...

My apologies for that ... Here is the code for that macro:


Code:
Sub Create_Reset_Variables()
With ActiveDocument.Variables
'When the userform opens up with a new document, these are the values displayed by default.

  .Item("varAuth").Value = "None"
  .Item("varProjNum").Value = "0"
  .Item("varProjName").Value = "None"
  .Item("varDefl").Value = 0
  
End With
FullDocumentUpdateFields
End Sub
Also, here is the code for the FullDocumentUpdateFields macro:


Code:
Sub FullDocumentUpdateFields()
Dim pRange As Word.Range
Dim oShp As Shape
Dim iLink As Long
Dim TOC As TableOfContents
Dim TOF As TableOfFigures
Dim TOA As TableOfAuthorities
Dim strAlerts As String
  strAlerts = Application.DisplayAlerts
  Application.DisplayAlerts = wdAlertsNone
  iLink = ActiveDocument.Sections(1).Headers(1).Range.StoryType
  For Each pRange In ActiveDocument.StoryRanges
    Do
      pRange.Fields.Update
      Select Case pRange.StoryType
        Case 6, 7, 8, 9, 10, 11
          If pRange.ShapeRange.Count > 0 Then
            For Each oShp In pRange.ShapeRange
                If oShp.TextFrame.HasText Then
                  oShp.TextFrame.TextRange.Fields.Update
                 End If
              Next oShp
            End If
      End Select
      Set pRange = pRange.NextStoryRange
    Loop Until pRange Is Nothing
  Next
  Application.DisplayAlerts = strAlerts
  For Each TOC In ActiveDocument.TablesOfContents
    TOC.Update
  Next TOC
  For Each TOA In ActiveDocument.TablesOfAuthorities
    TOA.Update
  Next TOA
  For Each TOF In ActiveDocument.TablesOfFigures
    TOF.Update
  Next TOF
lbl_Exit:
  Exit Sub
 End Sub
Quote:
Originally Posted by Guessed View Post
Get rid of the Set field - you can add a line in the Excel code to write that value into the Word document
Which Set field are you referring to?


Quote:
Originally Posted by Guessed View Post
Also disable the AutoNew macro until you can describe to us what you actually want that code to do.
In my first post I explained what I wanted the code to do ... Is there a specific part you'd like me to elaborate more on?
Reply With Quote