word macro
-
i am working on word macro in which i have to select few heading1 complete content and paste it into other document. In the document in every heading 1 i have placed bookmarks for start and end . So how to pick up the text . Private Sub CommandButton3_Click() Dim a As String Dim iCnt As Integer a = "" Application.ScreenUpdating = False Selection.HomeKey Unit:=wdStory Selection.Find.ClearFormatting Selection.Find.Style = ActiveDocument.Styles("Heading 1") Selection.MoveDown Unit:=wdWindow, Count:=1, Extend:=wdExtend 'With ActiveDocument.Select 'With Selection.SetRange Start:=Selection.Start, End:=ActiveDocument.Content.End Dim Label As String Do While Selection.Find.Execute With Selection.Find fndrepl "<#T" If .Find.Found Then iCnt = .MoveEndUntil("#>") If iCnt = 0 Then MsgBox "No closing tag found", vbOKOnly, "Error..." Exit Do End If .MoveRight wdCharacter, 2, wdExtend a = Selection.Text End If End With Loop End Sub