View Single Post
 
Old 03-24-2014, 07:41 PM
donaldadams1951 donaldadams1951 is offline Windows XP Office 2010 32bit
Advanced Beginner
 
Join Date: Dec 2013
Location: San Francisco Bay Area
Posts: 37
donaldadams1951 is on a distinguished road
Default OK. commented out the code and have the value...

i = 3

Code:
 
 Sub GetAndRemoveSectionByInstanceNumber()
  Dim strSearchString As String
  Dim ScnBrk As Long
  Dim i As Long
  
  ' start at top of document
'  Selection.HomeKey Unit:=wdStory
  
'  System.Cursor = wdCursorWait
   strSearchString = "Inst#: " & ReportInstance
  
  With ActiveDocument.Range
    With .Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Text = strSearchString
      .Replacement.Text = ""
      .Forward = True
      .Wrap = wdFindStop
      .Format = False
      .MatchWildcards = True
      .Execute
    End With
    If .Find.Found = True Then ' .Find.Found = True Then
      i = .Duplicate.Sections(1).index - 1
      MsgBox (CStr(i))
      ScnBrk = .Sections(i).PageSetup.SectionStart 'error here
      .Duplicate.Sections(1).Range.Delete
      .Sections(i).PageSetup.SectionStart = ScnBrk
    End If
  End With
End Sub
Reply With Quote