excel VBA to Automatically select Yes when prompted during mail merge -


i'd system automated users possible. right now, have code runs when user clicks button. code takes data intention of applying word document via mail merge.

everything works intended except there's message pops saying

opening document run following sql command:

select * 'tags$'

data database placed in document. want continue?

i need keep simple possible without risking users selecting "no" because they're confused. how can vba automatically proceed , accept data placement, had selected "yes"?

i tried using following code block alerts in hopes default "yes" , proceed, didn't work.

application.displayalerts = false 

this have

sub runmailmerge()      application.screenupdating = false      dim wdoutputname, wdinputname string     wdoutputname = thisworkbook.path & "\nametags - " _         & format(date, "d mmm yyyy")     wdinputname = thisworkbook.path & "\nametags.docx"      ' open mail merge layout file     dim wddoc object     set wddoc = getobject(wdinputname, "word.document")     wddoc.application.visible = true      wddoc.mailmerge          .maindocumenttype = wdformletters          .destination = wdsendtonewdocument          .suppressblanklines = true          .execute pause:=false     end      'application.screenupdating = true      'show , save output file     wddoc.application.visible = true     wddoc.application.activedocument.saveas wdoutputname      ' cleanup     wddoc.close savechanges:=false     'activedoc.close     set wddoc = nothing  end sub 

try setting displayalerts property in word (if that's alert coming from):

dim tmp long  tmp = wddoc.application.displayalerts   wddoc.application.displayalerts = wdalertsnone 'do action causes prompt wddoc.application.displayalerts = tmp 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -