Microsoft Word Macro to modify and paste clipboard text -


my goal to:

  1. copy text in pdf clipboard
  2. 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:

  1. remember current selection point paste clipboard data
  2. paste have in clipboard
  3. set ending point of pasted area
  4. 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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -