vba - VB script to export to pdf in Command Button (ActiveX) in Word 2010 -


ok, have word 2010 macro enabled template handy dandy forms people can fill out. have created button says "convert pdf" because people dont know how natively. entered vb editor of particular commandbutton want have functionality. here's whats in button:

private sub commandbutton1_click() sub convert_pdf()   dim desktoploc string  dim filename string  dim mypath string      desktoploc = createobject("wscript.shell").specialfolders("desktop")     filename = thisdocument.name     mypath = desktoploc & "\" & filename      activedocument.exportasfixedformat outputfilename:= _         mypath, _         exportformat:=wdexportformatpdf, openafterexport:=true, optimizefor:= _         wdexportoptimizeforprint, range:=wdexportalldocument, from:=1, to:=1, _         item:=wdexportdocumentcontent, includedocprops:=true, keepirm:=true, _         createbookmarks:=wdexportcreatenobookmarks, docstructuretags:=true, _         bitmapmissingfonts:=true, useiso19005_1:=false end sub end sub 

when run code get..... bam! compile error: expected end sub

if take out sub convert_pdf() , pertaining end sub, dont sub error messages, error message:

the file [file name] cannot opened beacause there problems contents. details: file corrupt , cannot opened. replace [file name] file's actual name.

i'll honest, i'm complete n00b @ vb , google turning out not being helpful far :/

any insight?

private sub commandbutton1_click()     convert_pdf end sub   sub convert_pdf()   dim desktoploc string  dim filename string  dim mypath string      desktoploc = createobject("wscript.shell").specialfolders("desktop")     filename = thisdocument.name     mypath = desktoploc & "\" & filename & ".pdf"      activedocument.exportasfixedformat outputfilename:= _         mypath, _         exportformat:=wdexportformatpdf, openafterexport:=true, optimizefor:= _         wdexportoptimizeforprint, range:=wdexportalldocument, from:=1, to:=1, _         item:=wdexportdocumentcontent, includedocprops:=true, keepirm:=true, _         createbookmarks:=wdexportcreatenobookmarks, docstructuretags:=true, _         bitmapmissingfonts:=true, useiso19005_1:=false end sub 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -