Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 11-27-2015, 05:51 AM
macropod's Avatar
macropod macropod is offline Extracting data from excel document using word Windows 7 64bit Extracting data from excel document using word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default


In that case, search for "*WO [0-9]{7,10} [A-Z0-9]{2}^13*"
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #17  
Old 11-27-2015, 10:21 PM
PRA007's Avatar
PRA007 PRA007 is offline Extracting data from excel document using word Windows 7 64bit Extracting data from excel document using word Office 2010 32bit
Competent Performer
Extracting data from excel document using word
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

I made mistake while asking.


This are two separate string from which I want to search first one exclusively.
1
Code:
WO 2015171641 A1¶
Some text¤
2
Code:
WO 2015171641 A1¶
Some text¶
US 2015328185 A1¶
opionally some more numbers like US 2015328185 A1¶
Reply With Quote
  #18  
Old 11-27-2015, 10:59 PM
macropod's Avatar
macropod macropod is offline Extracting data from excel document using word Windows 7 64bit Extracting data from excel document using word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
With ActiveDocument
  For Each Tbl In .Tables
    With Tbl
      bFit = .AllowAutoFit
      .AllowAutoFit = False
      j = .Rows.Count
      For i = 1 To j
        Application.StatusBar = "Processing row " & i & " of " & j
        With .Cell(i, 2).Range
          MsgBox .Paragraphs.Count
          If .Paragraphs.Count = 2 Then
            With .Paragraphs(1).Range
              With .Find
                .ClearFormatting
                .Replacement.ClearFormatting
                .Format = False
                .Forward = True
                .Wrap = wdFindStop
                .MatchWildcards = True
                .Text = "WO [0-9]{7,10} [A-Z0-9]{2}"
                .Execute
              End With
              If .Find.Found Then
                StrTxt = Replace(.Text, Chr(32), "")
                Set xlRng = xlWkSht.Range("A1:A" & lRow).Find(What:=StrTxt, _
                  LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False)
                If Not xlRng Is Nothing Then
                  l = xlRng.Row
                  With xlWkSht
                    'Get the worksheet data from columns 3 & 2
                    StrTxt = .Cells(l, 3).Text
                    If (StrTxt <> "") And (.Cells(l, 2).Text <> "") Then StrTxt = StrTxt & vbCr
                    StrTxt = StrTxt & .Cells(l, 2).Text
                    'Add the worksheet data from columns 3 & 2 to column 5 of the table
                    With Tbl.Cell(i, 5).Range
                      If Len(.Text) > 2 Then
                        .InsertBefore StrTxt & vbCr
                      Else
                        .InsertBefore StrTxt
                    End If
                    End With
                    'Get the worksheet data from columns 4 & 5
                    StrTxt = .Cells(xlRng.Row, 4).Text
                    If (StrTxt <> "") And (.Cells(l, 5).Text <> "") Then
                      StrTxt = StrTxt & vbCr & "Er.Prio: "
                    ElseIf .Cells(l, 5).Text <> "" Then
                      StrTxt = "Er.Prio: "
                    End If
                    StrTxt = StrTxt & .Cells(l, 5).Text
                    'Add the worksheet data from columns 4 & 5 to column 4 of the table
                    With Tbl.Cell(i, 4).Range
                      If Len(.Text) > 2 Then
                        .InsertBefore StrTxt & vbCr
                      Else
                        .InsertBefore StrTxt
                      End If
                    End With
                  End With
                End If
              End If
            End With
          End If
        End With
      Next
      .AllowAutoFit = bFit
    End With
  Next
End With
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #19  
Old 11-27-2015, 11:17 PM
PRA007's Avatar
PRA007 PRA007 is offline Extracting data from excel document using word Windows 7 64bit Extracting data from excel document using word Office 2010 32bit
Competent Performer
Extracting data from excel document using word
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

Left no stone unturned.
Can be marked as solved.
Reply With Quote
Reply

Tags
excel vba, word vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting data from excel document using word Extracting Data from Word Documents Atomizer Word VBA 3 08-24-2015 04:49 PM
Extracting data from excel document using word extracting data from word docs stubevh Word 2 03-04-2015 06:27 PM
Extracting data from excel document using word Extracting data from excel Eric855 Word 6 07-25-2013 08:02 AM
Extracting data from excel document using word Extracting text from a Word Doc into Excel dgcarlin Word VBA 1 07-06-2012 05:46 PM
Extracting Contacts Data from Excel Caesar Outlook 1 05-08-2011 05:54 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:51 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft