[[UPDATE: Apologies...I forgot the code block. Edited.]]
This is a question from one of my faculty, so I'll quote him directly, and preface this by saying I don't know VB (just the conduit here):
"In order to help an international student, I need to convert Youtube transcripts and Closed Captionings into readable text.
I wrote this routine for the purpose of eliminating time code marks from Youtube transcripts by invoking Visual Basic from within Microsoft Word. Since time codes are always on a separate line and since time codes must contain “:”, I am searching for the character “:” and then deleting the whole line in which it occurs. For some reason, the routine I have written, when completed, forces Word into a long unresponsive period (around 60-100 seconds) after which it works perfectly well. Any suggestions for avoiding that delay or for solving this problem within Word, without writing macros?"
Sub Deleteyt()
Dim oRng As Word.Range
Dim oRngDelete As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = ":"
While .Execute
oRng.Select
Set oRngDelete = ActiveDocument.Bookmarks("\Line").Range
oRngDelete.Delete
Wend
End With
End Sub
So the code works, there's just the long delay up front. Any ideas?