vba - Can not copy from Excel and paste to a Form Edit restricted Word document unless restriction is turned off -


i copying excel cell contents bookmark on form edit restricted (2010) word document paste if protection turned off.

the code have turn protection on again afterwards errors. correct code?

is there way make copy , paste without turning off protection?

second problem when text pasted bookmark font red (if manually entered on document in black). word default set black (i reset default measure). typing in new document in black, however, when word opens font icon shows red though checking default still shows black. can define font colour in vba override issue until is resolved or can suggest way fix word default?

sub arzbericht_brandstetter()  ' x - defined cell names -  artbrandpath   ,  artbranddoc  '                               excel          word bookmark ' x - defined cell names -  arzkrankenhaus       text65   dim wb workbook dim ws worksheet set wb = activeworkbook set ws = activesheet  dim wd object dim wddoc object dim brandstetterdoc object dim brandstetterpath string  dim f boolean  brandstetterpath = activesheet.range("artbrandpath").value & activesheet.range("artbranddoc").value & ".doc"  ' x  '    on error resume next  set brandstetterdoc = getobject(brandstetterpath)  if brandstetterdoc nothing     set wd = getobject(, "word.application")     if wd nothing         set wd = createobject("word.application")         if wd nothing             msgbox "failed start word!", vbcritical             exit sub         end if         f = true     end if     set brandstetterdoc = wd.documents.open(brandstetterpath)     if brandstetterdoc nothing         msgbox "failed open brandstetter document!" & vbnewline & _                    " check file directory correct", vbcritical         if f             wd.quit         end if         exit sub     end if     wd.visible = true else     brandstetterdoc.parent         .visible = true         .activate   '  turn protection off         activedocument             .unprotect "xxxxx"             .protect wdallowonlyrevisions, , password:="xxxxx"         end          brandstetterdoc.bookmarks("text65").range.text = ws.range("arzkrankenhaus").value   '  turn protection on   (restricted editing) '           activedocument.protect type:=wdallowonlyformfields, noreset:=true      end end if  end sub 

because formfield , not bookmark changing code below resolved strange red font issue. can copy document protected.

from brandstetterdoc.bookmarks("text65").range.text = ws.range("arzkrankenhaus").value activedocument.formfields("text65").result = ws.range("arzkrankenhaus").value 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -