Author | Topic: Empty pages when adding docs | |
---|---|---|
Hans Jelders | Empty pages when adding docs on Wed, 25 Aug 2010 00:03:06 +0200 In the codesnippet below I open a Word document and add several Word documents to it. I am sure that there are no empty pages at the end of the the documents I add . Still I get sometimes blank pages between the added pages in the final document. Does anyone know how to avoid that? Or is it possible to find out with activeX which page is empty and then delete just that empty page also with activeX? It would save me a lot of work because now I have to open a lot of documents to remove the empty pages. Many thanks for your help. FUNCTION MaakRapport1(cPeriode,cDatum,cStatus,aAfd,lShow) ******************************************************** LOCAL oWord, oDoc, oPara, oBM, i, oSelection, oRange, cDialog MEMVAR aPad cDialog := DC_WaitOn('Moment... open MS-Word') oWord:=CreateObject('Word.Application') oWord:visible:=lShow oWord:Application:DisplayAlerts:=.F. FOR i:=1 TO len(aAfd) IF !aAfd[i,1] LOOP ENDIF DC_Impl(cDialog) cDialog:=DC_WaitOn('Moment... Maken HLR van '+aAfd[i,2]) oWord:documents:open(aAfd[i,4]) //HLR_main.doc oDoc :=oWord:ActiveDocument oBM :=oDoc:Bookmarks oPara:=oDoc:paragraphs //Replace de Bookmarks met waarden ReplaceBookmark(oBM,"AFDELING",Trim(aAfd[i,3])+" ("+Upper(aAfd[i,2])+")") ReplaceBookmark(oBM,"PERIODE1",cPeriode) ReplaceBookmark(oBM,"PERIODE2",cPeriode) ReplaceBookmark(oBM,"DATUM" ,cDatum ) ReplaceBookmark(oBM,"STATUS" ,cStatus ) //voeg RWS dashboard met commentaar toe AddDoc(oPara,aAfd[i,5],'1.1 Dashboard RWS totaal DVS',.T.) //voeg DVS Dashboard met commentaar toe AddDoc(oPara,aAfd[i,6],'1.2 Besteding totaal DVS naar financieringsbron',.T.) //voeg algemene inkoopparagraaf toe AddDoc(oPara,aAfd[i,7],'1.3 Inkoop DVS breed',.T.) //Voeg cockpit totaal DVS toe AddDoc(oPara,aAfd[i,8],'1.4 Cockpit totaal DVS',.T.) //voeg mijlpalen toe AddDoc(oPara,aAfd[i,9],'Mijlpalen',.T.) //voeg csa's toe AddDoc(oPara,aAfd[i,10],'2.2 Control Self Assesment',.T.) //voeg voortgang productie toe AddDoc(oPara,aAfd[i,11],'2.3 Externe productiekosten (EPK)',.T.) //voeg grafiek epk toe AddDoc(oPara,aAfd[i,12],'Voorspelling voortgang externe productiekosten',.T.) //voeg interne kosten toe AddDoc(oPara,aAfd[i,13],'2.4 Interne kosten (IK)',.T.) //voeg inkoopparagraaf toe AddDoc(oPara,aAfd[i,14],'2.5 Inkoop',.T.) //voeg HRM paragraaf toe AddDoc(oPara,aAfd[i,15],'2.6 HRM',.T.) //voeg restant toe IF File(aPad[6]+aAfd[i,2]+'_HLR_einde.doc') AddDoc(oPara,aPad[6]+aAfd[i,2]+'_HLR_einde.doc','Hoofdstuk 3',.T.) ELSE AddDoc(oPara,aAfd[i,16],'Hoofdstuk 3',.T.) ENDIF //zet lettertype om naar Verdana in het gehele document oSelection:=oWord:Selection oRange:=oSelection:Range oRange:WholeStory() oRange:Font:Name="Verdana" oRange:Style="Standaard" //does not work well oDoc:saveas(aPad[3]+Trim(aAfd[i,2])+'.doc') oDoc:Close(wdDoNotSaveChanges) oDoc:Destroy() NEXT i oWord:Quit() oWord:Destroy() DC_Impl(cDialog) DC_WinAlert('Klaar!') RETURN NIL FUNCTION AddDoc(oPara,cFile,cText,lNewPage,lKop) ************************************************ DEFAULT lNewPage:=.T. DEFAULT lKop:=.T. IIF(lNewPage,oPara:last:range:InsertBreak(wdPageBreak),NIL) oPara:add() IF !File(cFile) IF lKop PrintLine(oPara,cText+' ditmaal niet beschikbaar',12,1) ENDIF ELSE oPara:last:range:InsertFile(cFile,"",.F.,.F.,.F.) ENDIF RETURN NIL |