79239278

Date: 2024-11-30 10:05:07
Score: 3
Natty:
Report link

I am having problems with Case 'No' only. Let me explain, Under Case "No" i have want to find with range in coulmn A(there are multiple cells to find with word doument) and paste value in 2 different way. Let assume 1 way is to paster value in the next para . So i used below code and it works

Set wordRange = newWordDoc.Content

            With wordRange.Find
                .Text = Left(description, 255)
                .Replacement.Text = ""
                .Forward = True
                .Wrap = 1
                .Format = False
                .MatchCase = False
                .MatchWholeWord = False
                .MatchWildcards = False
                .MatchSoundsLike = False
                .MatchAllWordForms = False
            End With
            

If wordRange.Find.Execute Then ' Paste the value in the next paragraph after the description wordRange.Collapse Direction:=0 wordRange.MoveEnd Unit:=4, Count:=1 wordRange.Text = wordRange.Text & valueToPaste wordRange.Font.Bold = False End If

however there are some para where table are appearing in the word doc and these have 3 columns , i want to paste with under table at specificed row let support ....in excel column a text appearing "A.4" at cell A320 the same text is in word document "A.4" is appearing and there is table after than , so i want to paste value from column E (say cell E320) with function cell offset (0,5) under row 2 column 3 of the table (2,3) appearing in the word document , then "A.4" is also appearing in cell A321 of in excel now i want to paste value of cell E320 in the "A.4" para appearing in word but now in the table row 3 column 3 (3,3) . I used the below code but its only pasting value of E319 in row 2 and 3 .....so how can i define multiple criteria for pasting value for example then next criteria for "A.5"..... "? also the how to limit the first criteria .Text = Left(description, 255) to not execute on A.4 , A.5 as its is find a paste funciton for all the value matched

Else If wordRange.Find.Execute.Text="A.4" Then If wordRange.Tables.Count > 0 Then ' Paste the value in the respective row and last column

        Set table = wordRange.Next(wdParagraph).Tables(1)
        table.cell(2,3).Range = valueToPaste
             
Reasons:
  • Blacklisted phrase (0.5): how can i
  • Blacklisted phrase (1): I am having problem
  • RegEx Blacklisted phrase (1): i want
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Anas Zubair