' ' version : $Revision: 1.7 $ ' Sub DoWord(theTemplate,AddrLines) Dim theApp Dim theDoc Dim theVBComponent Dim theCodeLineNr Dim theCodeLine Dim theCommandBar Set theApp = CreateObject("Word.Application") theApp.Visible=True theApp.Activate Set theDoc = theApp.Application.Documents.Add(theTemplate) Set theVBComponent = theApp.VBE.VBProjects("TemplateProject").VBComponents.Item("ModStandaarden") theCodeLineNr = theVBComponent.CodeModule.ProcBodyLine("VNM_BriefOpstarten", vbext_pk_Proc) theCodeLine = "UsrFrmBrief.txtOrganisatie.MultiLine = True" theVBComponent.CodeModule.InsertLines theCodeLineNr + 1, theCodeLine theCodeLine = "UsrFrmBrief.txtOrganisatie.Text = """ & SmartConcat(AddrLines(1), AddrLines(2)) & """" theVBComponent.CodeModule.InsertLines theCodeLineNr + 2, theCodeLine theCodeLine = "UsrFrmBrief.txtAfdeling.Text = """ & AddrLines(3) & """" theVBComponent.CodeModule.InsertLines theCodeLineNr + 3, theCodeLine theCodeLine = "UsrFrmBrief.txtNaam.Text = """ & AddrLines(4) & """" theVBComponent.CodeModule.InsertLines theCodeLineNr + 4, theCodeLine theCodeLine = "UsrFrmBrief.txtAdres.Text = """ & AddrLines(5) & """" theVBComponent.CodeModule.InsertLines theCodeLineNr + 5, theCodeLine theCodeLine = "UsrFrmBrief.txtHuisnummer.Text = """ & AddrLines(6) & """" theVBComponent.CodeModule.InsertLines theCodeLineNr + 6, theCodeLine theCodeLine = "UsrFrmBrief.txtToevoeging.Text = """ & AddrLines(7) & """" theVBComponent.CodeModule.InsertLines theCodeLineNr + 7, theCodeLine theCodeLine = "UsrFrmBrief.txtPostcode.Text = """ & AddrLines(8) & """" theVBComponent.CodeModule.InsertLines theCodeLineNr + 8, theCodeLine theCodeLine = "UsrFrmBrief.txtPlaats.Text = """ & AddrLines(9) & """" theVBComponent.CodeModule.InsertLines theCodeLineNr + 9, theCodeLine theCodeLine = "UsrFrmBrief.txtLand.Text = """ & AddrLines(10) & """" theVBComponent.CodeModule.InsertLines theCodeLineNr + 10, theCodeLine theCodeLine = "UsrFrmBrief.TxtAanhef.Text = """ & AddrLines(11) & """" theVBComponent.CodeModule.InsertLines theCodeLineNr + 11, theCodeLine ' Wijziging 19-12-2006: Maak het veld doorkiesnummer leeg, de streepjes moeten weg theCodeLine = "UsrFrmBrief.TxtDoorkiesNr.Text = """ & """" theVBComponent.CodeModule.InsertLines theCodeLineNr + 12, theCodeLine 'theCodeLine = "UsrFrmBrief.txtOrganisatie.Height = 48" 'theVBComponent.CodeModule.InsertLines theCodeLineNr + 12, theCodeLine theDoc.AttachedTemplate.Saved = True Set theCommandBar = theApp.CommandBars("Menu Bar").Controls(2).CommandBar theCommandBar.Controls(1).Execute theApp.Application.Documents("Document1").Close(wdDoNotSaveChanges) Set theDoc = Nothing Set theVBComponent = Nothing Set theCommandBar = Nothing Set theApp = Nothing End Sub Function SmartConcat(string1, string2) If string1 = "" Then SmartConcat = string2 ElseIf string2 = "" Then SmartConcat = string1 Else SmartConcat = string1 & Chr(11) & string2 End if End Function Sub exportToWord(lines) Dim theApp Dim theDoc Set theApp = CreateObject("Word.Application") theApp.Visible=True theApp.Activate Set theDoc = theApp.Application.Documents.Add() For Each line in lines theDoc.Content.InsertAfter(line) theDoc.Content.InsertAfter(Chr(13) + Chr(10)) Next Set theDoc = Nothing Set theApp = Nothing End Sub Sub exportToWord(pathToFile, fileUrl) Dim theApp Dim theDoc Set theApp = CreateObject("Word.Application") theApp.Visible=True theApp.Activate 'Set theDoc = theApp.Application.Documents.Open(pathToFile) Set theDoc = theApp.Application.Documents.Open(fileUrl) Set theDoc = Nothing Set theApp = Nothing End Sub Sub openInExcel(fileUrl) ' ' Create an Excel workbook/worksheet ' Dim app Dim textFileName Dim saveFileName ' 'xlTextQualifierDoubleQuote = 1 'xlTextQualifierSingleQuote = 2 xlTextQualifierNone = -4142 'textFileName = "c:\temp\export.txt" 'textFileName = "http://server2.crossmarx.nl/jsp/export.txt" ' Set app = CreateObject("Excel.Application") app.visible = True app.Workbooks.Add 'textFileName = app.GetOpenFilename("Text Files (*.txt), *.txt") 'fileUrl = "http://localhost/engine?app=jsp&service=downloader&type=export&name=export.txt" app.Workbooks.OpenText fileUrl, 1, 1, 1, xlTextQualifierNone, false, false, true, false, false 'app.Workbooks.OpenText textFileName, 1, 1, 1, xlTextQualifierNone, false, false, true, false, false 'Do 'saveFileName = app.GetSaveAsFilename 'Loop Until saveFileName <> False 'app.ActiveWorkbook.SaveAs(saveFileName) End Sub Sub createMail(toAddresses, ccAddresses, bccAddresses, message) Dim outlookApp Dim newMail Set outlookApp = createobject("Outlook.Application") Set newMail = outlookApp.createitem(0) newMail.To = toAddresses newMail.cc = ccAddresses newMail.bcc = bccAddresses newMail.subject = "" newMail.body = message newMail.display Set newMail = nothing Set outlookApp = nothing End Sub