Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Let me post this again because I don't think I explained this well th first go around: The code below opens up a word doc, looks for the word "Primary Key: then gives me the corresponding answer. However, I require a twea since there are times when the word "Primary Key:" is followed b unwanted spaces, no spaces, or tabs. It works great if there is on space, but it doesn't work if there are no spaces after the colon, o there are more than one space. I have marked the problem area with UPPER CASE comments. I have tried tweaking the code myself, but I'm new to this VBA. ![]() ' Get Word doc 'strDoc = "C:\MyDocName" strDoc = "C:\Documents and Settings\edward.millis\Desktop\TestDoc.doc" Set docWord = appWord.Documents.Open(strDoc) ' Set Word range Set rngWord = docWord.Content ' Find first term rngWord.Find.Execute _ '******PROBLEM STARTS HERE*********** FindText:="Primary Key:", MatchWildcards:=False, _ Wrap:=wdFindStop, Forward:=True ' Reset range to get number rngWord.Collapse wdCollapseEnd Do rngWord.MoveStart Unit:=wdCharacter, Count:=1 numKey = Trim(rngWord.Text) Loop Until Right(numKey, 1) < " " rngWord.MoveEnd Unit:=wdWord, Count:=1 ' Put number into variable numKey = Trim(rngWord.Text -- pikapika1 ----------------------------------------------------------------------- pikapika13's Profile: http://www.excelforum.com/member.php...fo&userid=1089 View this thread: http://www.excelforum.com/showthread.php?threadid=57086 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I get Excel to ignore "a", "an", "the" when sorting? | Excel Discussion (Misc queries) | |||
=IF(ISERROR(SEARCH("insurance",A125,1)),"","*") | Excel Worksheet Functions | |||
Copy column range of "single word" cells with spaces to a single c | Excel Discussion (Misc queries) | |||
Search for the word "continued", if found, delete that row + 10 rows above | Excel Programming | |||
Search for the word "continued", if found, delete that row + 10 rows above | Excel Programming |