Two clicks to generate word document from access form, with double rich text copied using vba -



Two clicks to generate word document from access form, with double rich text copied using vba -

i've been working in exporting rtf (rich text) form memo field in access 2010 word file bookmark. problem is necessary 2 clicks open word document, , then, text inserted twice. i'm still not able find problem.

here code:

option compare database private sub comando72_click() 'saves current record --> me.dirty = false dim appword word.application dim doc word.document dim objword object '' word.application dim fso object '' filesystemobject dim f object '' textstream dim myhtml string dim tempfilespec string ' grab formatted text memo field myhtml = dlookup("descripactivaejecutarse", "planificacionserviciosinstitucionales", "idpsi = form!idpsi") set fso = createobject("scripting.filesystemobject") '' new filesystemobject tempfilespec = fso.getspecialfolder(2) & "\" & fso.gettempname & ".htm" '' write temporary .htm file set f = fso.createtextfile(tempfilespec, true) f.write "<html>" & myhtml & "</html>" f.close set f = nil set fso = nil 'set appword object variable running instance of word. set appword = getobject(, "word.application") if err.number <> 0 'if word isn't open, create new instance of word. set appword = new word.application end if 'set doc future use. set doc = appword.documents.open("c:\users\earias\documents\solicitud-yachay-automatica2.docx", , true) 'true default (just reading). 'locates bookmark , inserts file appword.selection.goto what:=wdgotobookmark, name:="bookmark_1" appword.selection.insertfile tempfilespec set doc = nil set appword = nil exit sub errhandler: msgbox err.number & ": " & err.description end sub

if pressing button twice run procedure twice?

in terms of current code, after line set doc = appword.documents.open add together following;

doc.visible = true

this should enable view document that's open when press button once. prevent window popping instead of setting visible do;

doc.saveas "path here"

then set nil , close off , file saved want saved without needing manually save each time.

you @ setting simple mail service merge template , saving-as template whichever format take , break mailmerge link (my preferred method).

let me know how on!

vba click double acc

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -