Underwood
12-23-2016, 01:15 AM
Hello all,
Thanks for the help with the initial steps of my extractor project.
At this point, I think a script to successfully move already highlighted text (from previous thread) is the last piece.
The code below will copy/paste highlighted text into a new document, but it's unfinished.
How might I add the following elements to the script posted below?:
- Bulleting all pastes
- A bolded header (ideally, one that somehow retrieves the search term from another sub... haven't done my homework on that, yet)
- No blank lines when bulleting (maybe something that sweeps after all the terms are pasted down)
- Returns to header upon pasting/formatting (basically restarts so you can run it again with another search term)
Graphical representation of wishlist above:
17892
Sub Export_Highlights()
Dim objWord As Word.Application
Dim doc As Word.Document
Dim oneword
Dim i As Integer
i = 0
Set objWord = CreateObject("Word.Application")
With objWord
.Visible = True
Set doc = .Documents.Add
End With
With objWord.selection
.Font.Name = "Calibri"
.Font.Size = 10.5
For Each Char In ActiveDocument.Characters
If Char.HighlightColorIndex = wdYellow Then
i = 1
oneword = Char.Text
.TypeText oneword
Else
If i = 1 Then
.TypeText vbCrLf
i = 0
End If
End If
Next
End With
doc.Activate
End Sub
Thank you for all your help, so far.
I intend on making this into a resource for my fellow pharmacy students.
No sense in searching 1000x like a caveman.
~DH
Thanks for the help with the initial steps of my extractor project.
At this point, I think a script to successfully move already highlighted text (from previous thread) is the last piece.
The code below will copy/paste highlighted text into a new document, but it's unfinished.
How might I add the following elements to the script posted below?:
- Bulleting all pastes
- A bolded header (ideally, one that somehow retrieves the search term from another sub... haven't done my homework on that, yet)
- No blank lines when bulleting (maybe something that sweeps after all the terms are pasted down)
- Returns to header upon pasting/formatting (basically restarts so you can run it again with another search term)
Graphical representation of wishlist above:
17892
Sub Export_Highlights()
Dim objWord As Word.Application
Dim doc As Word.Document
Dim oneword
Dim i As Integer
i = 0
Set objWord = CreateObject("Word.Application")
With objWord
.Visible = True
Set doc = .Documents.Add
End With
With objWord.selection
.Font.Name = "Calibri"
.Font.Size = 10.5
For Each Char In ActiveDocument.Characters
If Char.HighlightColorIndex = wdYellow Then
i = 1
oneword = Char.Text
.TypeText oneword
Else
If i = 1 Then
.TypeText vbCrLf
i = 0
End If
End If
Next
End With
doc.Activate
End Sub
Thank you for all your help, so far.
I intend on making this into a resource for my fellow pharmacy students.
No sense in searching 1000x like a caveman.
~DH