Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
A1sysman A1sysman is offline
external usenet poster
 
Posts: 6
Default Word2003 and UINs defined elsewhe resolving, how to?

Hi all, I asked yesterday, VBA scripting was suggested. I was hoping for
advise on how to run a macro to resolve the UINs from either a csv or an
Excel document. Any futher advise please ...

Can Word be configured to use a csv lookup table or an Excel spread sheet?

Below are examples of the specifics:

Current structure and data in the Word doc €¦

Sponsor1233/Sponsor
Sponsor44/Sponsor

Intended output after using (macro?) look up €¦

SponsorJOHN BROWN/Sponsor
SponsorPAUL WHITE/Sponsor

Where there the lookup uses a csv file generated from an Excel spreadsheet,
that reads€¦

Brown,John,1233
White,Paul,44
Green,Nick,9062
.... and so on.

If the answer is "yes, Word can do this", how please?

Thanks,

A1sysman

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Helmut Weber[_2_] Helmut Weber[_2_] is offline
external usenet poster
 
Posts: 45
Default Word2003 and UINs defined elsewhe resolving, how to?

Hi A1sysman,

sorry, there are so many ways,
and it isn't that easy and
better ask in ...word.vba.general,
and I didn't care about speed or effective coding,
but anyway, just for showing that it is possible:

Sub Test003()
Dim rngDocNow As Range ' the active document's range
Dim rngDocCsv As Range ' the csv-document's range
Dim strNumber As String ' the number to be searched for
Dim strName() As String ' the line where the number is found
Dim strReplace As String ' the string to replace the number with
Dim docCsv As Document ' the csv-document
Dim DocNow As Document ' the active document
' -------------------------------------------------------
Set DocNow = ActiveDocument
Set docCsv = Documents.Open("c:\test\test.csv")
DocNow.Activate
Set rngDocNow = DocNow.Range
With rngDocNow.Find
.Text = "\Sponsor\*\/Sponsor\"
.MatchWildcards = True
While .Execute
strNumber = rngDocNow.Text
strNumber = Left(strNumber, Len(strNumber) - 10)
strNumber = Right(strNumber, Len(strNumber) - 9)
' MsgBox strNumber ' for testing
Set rngDocCsv = docCsv.Range
With rngDocCsv.Find
.Text = "," & strNumber & vbCrLf
If .Execute Then
strName = Split(rngDocCsv.Paragraphs(1).Range.Text, ",")
strReplace = UCase(strName(1))
strReplace = strReplace & " "
strReplace = strReplace & UCase(strName(0))
rngDocNow.Text = _
"Sponsor" & strReplace & "/Sponsor"
' MsgBox strReplace ' for testing
End If
rngDocNow.Collapse Direction:=wdCollapseEnd
End With
Wend
End With
docCsv.Close
Set docCsv = Nothing
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
A1sysman A1sysman is offline
external usenet poster
 
Posts: 6
Default Word2003 and UINs defined elsewhe resolving, how to?

Hi Helmut,

Thank you for your reply. You have been a great help to me.

Rgds,

A1sysman

"Helmut Weber" wrote:

Hi A1sysman,

sorry, there are so many ways,
and it isn't that easy and
better ask in ...word.vba.general,
and I didn't care about speed or effective coding,
but anyway, just for showing that it is possible:

Sub Test003()
Dim rngDocNow As Range ' the active document's range
Dim rngDocCsv As Range ' the csv-document's range
Dim strNumber As String ' the number to be searched for
Dim strName() As String ' the line where the number is found
Dim strReplace As String ' the string to replace the number with
Dim docCsv As Document ' the csv-document
Dim DocNow As Document ' the active document
' -------------------------------------------------------
Set DocNow = ActiveDocument
Set docCsv = Documents.Open("c:\test\test.csv")
DocNow.Activate
Set rngDocNow = DocNow.Range
With rngDocNow.Find
.Text = "\Sponsor\*\/Sponsor\"
.MatchWildcards = True
While .Execute
strNumber = rngDocNow.Text
strNumber = Left(strNumber, Len(strNumber) - 10)
strNumber = Right(strNumber, Len(strNumber) - 9)
' MsgBox strNumber ' for testing
Set rngDocCsv = docCsv.Range
With rngDocCsv.Find
.Text = "," & strNumber & vbCrLf
If .Execute Then
strName = Split(rngDocCsv.Paragraphs(1).Range.Text, ",")
strReplace = UCase(strName(1))
strReplace = strReplace & " "
strReplace = strReplace & UCase(strName(0))
rngDocNow.Text = _
"Sponsor" & strReplace & "/Sponsor"
' MsgBox strReplace ' for testing
End If
rngDocNow.Collapse Direction:=wdCollapseEnd
End With
Wend
End With
docCsv.Close
Set docCsv = Nothing
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Please Help, URGENT! About Microsoft Office 2003 Activation + UIns - Microsoft Word Help 12 September 19th 08 09:36 PM
Inserting pre-defined text at pre-defined location upon tick! gianni Microsoft Word Help 4 June 2nd 07 12:03 AM
Macros function not defined. Paloma Microsoft Word Help 3 December 20th 06 06:50 AM
Numbering with defined series Carole Hunt Microsoft Word Help 1 April 12th 06 01:00 PM
user-defined sort transcribe New Users 1 January 29th 05 02:22 AM


All times are GMT +1. The time now is 08:41 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"