Microsoft Word Macro to modify and paste clipboard text -
my goal to:
- copy text in pdf clipboard
- in single move (using macro, suppose), paste text ms word while
- replacing line breaks space
- matching destination's formatting
i have accomplished create macro replaces line breaks spaces in whole documented, or in selected part, not in clipboard. currently, macro looks this:
selection.find.execute replace:=wdreplaceall selection.wholestory selection.pasteandformat (wdformatoriginalformatting) selection.find.clearformatting selection.find.replacement.clearformatting selection.find .text = "^p" .replacement.text = " " .forward = true .wrap = wdfindcontinue .format = false .matchcase = false .matchwholeword = false .matchwildcards = false .matchsoundslike = false .matchallwordforms = false end
which replaces whole text @ moment... on how apply replacement clipboard , paste replaced snippet appreciated! in advance.
i propose way:
- remember current selection point paste clipboard data
- paste have in clipboard
- set ending point of pasted area
- do replacement pasted range of text.
the following solution based partially on code question. necessary (for test) commented.
sub replacement_for_selection() 'selection.find.execute replace:=wdreplaceall 'selection.wholestory dim rngfrom, rngto rngfrom = selection.start selection.pasteandformat (wdformatoriginalformatting) rngto = selection.end activedocument.range(rngfrom, rngto).select selection.find.clearformatting selection.find.replacement.clearformatting selection.find .text = "^p" .replacement.text = " " .forward = false '!!! .wrap = wdfindstop '!!! .format = false .matchcase = false .matchwholeword = false .matchwildcards = false .matchsoundslike = false .matchallwordforms = false end selection.find.execute , , , , , , , , , , wdreplaceall end sub
Comments
Post a Comment