P
pavja2
So, I am trying to create a VBA macro that selects everything that is
a certain style (i.e. Heading 2) copies it and then pastes the text
into an excel spreadsheet. Is such a macro possible? I know that when
I try to record it using the macro recorder It does not work...This is
what the recorder gives me:
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles( _
"Heading 2,Heading 2 Char Char2 Char1,Heading 2 Char1 Char
Char1 Char,Heading 2 Char Char Char Char1 Char,Heading 2 Char1 Char
Char Char1 Char Char1,Heading 2 Char Char Char Char Char1 Char
Char,Heading 2 Char2 Char Char Char Char Char,Heading 2 Cha" _
)
Selection.Find.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
I have not yet tried to incorporated the copying or excel elements,
but since it doesn't select the neccesary text neither of those would
work anyway. If anyone could tell me how to go about this it would be
much appreciated, I know how to do it manually under the "Format-
styles" menu, but I would like to assign a key-stroke to this
function.
Thanks,
a certain style (i.e. Heading 2) copies it and then pastes the text
into an excel spreadsheet. Is such a macro possible? I know that when
I try to record it using the macro recorder It does not work...This is
what the recorder gives me:
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles( _
"Heading 2,Heading 2 Char Char2 Char1,Heading 2 Char1 Char
Char1 Char,Heading 2 Char Char Char Char1 Char,Heading 2 Char1 Char
Char Char1 Char Char1,Heading 2 Char Char Char Char Char1 Char
Char,Heading 2 Char2 Char Char Char Char Char,Heading 2 Cha" _
)
Selection.Find.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
I have not yet tried to incorporated the copying or excel elements,
but since it doesn't select the neccesary text neither of those would
work anyway. If anyone could tell me how to go about this it would be
much appreciated, I know how to do it manually under the "Format-
styles" menu, but I would like to assign a key-stroke to this
function.
Thanks,