I
Ian Richardson
Hi
I'm trying to convert several tables in Word 2003 to standard tabbed text so
I can import it into Excel.
I've recorded a macro that converts the table to text seperated by tabs but
then I need to replace the remainder paragraphs with tabs. Recording the
macro goes OK.
The table gets converted and the text is still selected so Find, Replace ^p
with ^t and I get asked to check all the doc after it's replaced the
selection, I say No and close the dialog box. When I run the macro it
converts ALL paras to tabs and not just the selection. This is the macro I've
recorded. Am I missing something??
Many thanks
Ian
Sub Macrotable()
'
'
' Macro recorded 01/06/2009 by me
'
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.ConvertToTable Separator:=wdSeparateByDefaultListSeparator, _
NumColumns:=3, NumRows:=1, AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
.Style = "Table Grid"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = True
End With
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.Tables(1).Select
Selection.Rows.ConvertToText Separator:=wdSeparateByTabs, NestedTables:= _
True
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = "^t"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Selection.Find.Execute Replace:=wdReplaceAll
End With
Selection.MoveDown Unit:=wdLine, Count:=1
End Sub
I'm trying to convert several tables in Word 2003 to standard tabbed text so
I can import it into Excel.
I've recorded a macro that converts the table to text seperated by tabs but
then I need to replace the remainder paragraphs with tabs. Recording the
macro goes OK.
The table gets converted and the text is still selected so Find, Replace ^p
with ^t and I get asked to check all the doc after it's replaced the
selection, I say No and close the dialog box. When I run the macro it
converts ALL paras to tabs and not just the selection. This is the macro I've
recorded. Am I missing something??
Many thanks
Ian
Sub Macrotable()
'
'
' Macro recorded 01/06/2009 by me
'
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.ConvertToTable Separator:=wdSeparateByDefaultListSeparator, _
NumColumns:=3, NumRows:=1, AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
.Style = "Table Grid"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = True
End With
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.Tables(1).Select
Selection.Rows.ConvertToText Separator:=wdSeparateByTabs, NestedTables:= _
True
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = "^t"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Selection.Find.Execute Replace:=wdReplaceAll
End With
Selection.MoveDown Unit:=wdLine, Count:=1
End Sub