Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Edit Word Table from Excel using vba code

Hi,

Office 2003.
I'm trying to delete paragraph marks from inside the tables of a Word
Document opened via VBA code from Excel but Excel keeps crashing on me. Can
anyone suggest a correction please? Each table is selected ok but doesn't
seem to like the ".Replacement.Text" line in code below:-

Sub ReplaceParaMarksInTable()
Dim intTables As Integer
Dim intX As Integer

If ActiveDocument.Tables.Count = 1 Then
intTables = ActiveDocument.Tables.Count
For intX = 3 To intTables
With ActiveDocument.Tables(intX).Range
.Select
.Find.ClearFormatting
.Find.Replacement.ClearFormatting
With .Find
.Text = "^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
.Find.Execute

End With
Next intX
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Edit Word Table from Excel using vba code

On 31 Aug, 10:40, John_R_Fry
wrote:
Hi,

Office 2003.
I'm trying to delete paragraph marks from inside the tables of a Word
Document opened via VBA code from Excel but Excel keeps crashing on me. Can
anyone suggest a correction please? Each table is selected ok but doesn't
seem to like the ".Replacement.Text" line in code below:-

Sub ReplaceParaMarksInTable()
Dim intTables As Integer
Dim intX As Integer

If ActiveDocument.Tables.Count = 1 Then
intTables = ActiveDocument.Tables.Count
For intX = 3 To intTables
With ActiveDocument.Tables(intX).Range
.Select
.Find.ClearFormatting
.Find.Replacement.ClearFormatting
With .Find
.Text = "^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
.Find.Execute

End With
Next intX
End If
End Sub


Are you sure it's that line - I would suspect the wdFindContinue
myself - this is a Word constant, and should be replaced with it's
numeric value of 1

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I paste an EXCEL chart from a word doc into EXCEL and edit it camper641 Excel Discussion (Misc queries) 1 November 18th 08 02:04 PM
Can't edit Excel or Word documents daxdarko Excel Discussion (Misc queries) 0 October 29th 08 05:50 PM
how to protect a word art in excel from edit sancbey Excel Worksheet Functions 0 September 30th 05 12:35 PM
Code to Delete Empty Rows in a Word Table Araknia777 via OfficeKB.com Excel Programming 0 August 9th 05 06:23 PM
code to export excel table to word mcope Excel Programming 4 July 26th 05 02:20 PM


All times are GMT +1. The time now is 04:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"