Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 2nd, 2004, 12:25 PM
Registered User
 
Join Date: Dec 2004
Location: , , United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Issue w/ IF/FIND statements..

I have placed the attached code into the code window of MS Word's Normal.dot in the Document_open event so that it will run automatically (I highlight all the docs that I want affected by this script and press enter to fire them all off - this method works fine - jsut some background)

The code works, no errors, with the exception of the first part fo the if statement. I tested this on 3 documents.

one that contained the text: LOCATION(S): THERE
one that contained the text: LOCATION(S): HERE
one that contained the text: LOCATION(S): THERE; HERE

The idea is that if it has the word: HERE in it, then write the filename and title to a log file..

after running all three of these test docs through the script, only the one that said: LOCATION(S): THERE; HERE was in the log

my question is, what am i doing wrong that the one that contained the text: LOCATION(S): HERE does not show up in my log?

I WOULD GREATLY APPRECIATE ANY HELP IN THIS!!! :)


Code:
Sub notThere()

    Selection.HomeKey Unit:=wdStory ' just to be safe, start at the top of doc
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader ' view header
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = "LOCATION(S):" & vbTab & "HERE"
        If .Execute = True Then
            Call getTitle 'get title and filename and write to log file
            Exit Sub
        Else
            Selection.HomeKey Unit:=wdStory ' just to be safe, start at the top of doc
            ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader ' view header
            Selection.Find.ClearFormatting
            With Selection.Find
                .Text = "LOCATION(S):" & vbTab & "THERE; HERE"
                If .Execute = True Then
                    Call getTitle 'get title and filename and write to log file
                Else
                    ActiveDocument.Close 'if it is neither of these options, kill document
                End If
            End With
        End If
    End With
End Sub
Reply With Quote
  #2 (permalink)  
Old December 7th, 2004, 10:21 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

The only thing I can think of is that someone didn't type a TAB between the colon and the word "HERE". Perhaps the person typed one or two spaces after the colon, so you're not finding it.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
  #3 (permalink)  
Old December 7th, 2004, 02:35 PM
Registered User
 
Join Date: Dec 2004
Location: , , United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

bingo - this was the issue - thanks for the reply

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
if statements brainchild Javascript 2 March 1st, 2007 05:08 AM
Open Word Doc from Access - find, find next save donaldmaloney Access VBA 1 May 25th, 2005 11:09 AM
If, else if statements Joel JSP Basics 0 March 18th, 2004 05:17 PM
Create a find and a find and replace in VB.NET snowy0 VB How-To 0 January 26th, 2004 06:03 PM



All times are GMT -4. The time now is 05:25 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.