cliffhanger9
MIS
Hi all!
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 - just 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!!!
====================
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
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 - just 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!!!
====================
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