Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Regular text + word doc into HTML
Message
De
22/04/2005 10:22:41
 
 
À
22/04/2005 09:07:00
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01007424
Message ID:
01007452
Vues:
19
[SORRY: FORGOT TO USE PRE IN FIRST POST!]

Hi Peter,

You didn't say specifically what you were trying to improve over the current code, so I'll just toss in some observations:

1. Your HTML is not valid. You need to include opening and closing TD elements inside your TR, even for single cell rows. (Browsers "cope" with the TD missing, but it's not good practice.)

2. Instead of using HR tags (which are close to deprecated) to divide content, you should use border styles. Your current code also only places HR's before the LETTER types, which means you're not getting visual separation between FILENOTE types.

3. Are you trying to improve the look of the text extracted from Word? If so, one idea might be to parse the Paragraphs collection of the document, rather than pulling the whole text and using BR elements as dividers. This would get you a step closer to having your HTML match the semantics of the Word document. Example:
loPars = THISFORM.oWord.ActiveDocument.Paragraphs
FOR EACH loPar IN loPars
  lcText = loPar.Range.Text
  TEXT TO lcHTML NOSHOW TEXTMERGE ADDITIVE PRETEXT 3
    <p><<m.lcText>></p>

  ENDTEXT
ENDFOR
Let us know what more you're trying to improve, and we may have other ideas.

-- Randy


>I have an application where we have regular text (memo field) and letters in .doc format intersperced. They need to be combined into HTML so they can be shown (and printed) together.
>Does anyone have a good way of doing this.
>
>It will be displayed in a browser object.
>Here is what I do now but I would like to have some better code:
>
>			lchtml=[<html><body><table>]
>			SELECT ccprint
>			SCAN FOR docType="FILENOTE" OR docType="LETTER"
>				DO CASE
>					CASE docType="FILENOTE"
>						TEXT TO lcHTML NOSHOW TEXTMERGE ADDITIVE
>							<tr><<ccprint.notes>></tr>
>						ENDTEXT
>					CASE docType="LETTER"
>						***
>						lcDocName=ADDBS(SYS(5)+SYS(2003))+"DocDir\WordDocs\"+ALLTRIM(ccprint.docpath)+".doc"
>						IF FILE(lcDocName)
>							THISFORM.oWord.visible=.f.
>							THISFORM.oWord.documents.OPEN(lcDocName,,.T.)
>
>							xNt=THISFORM.oWord.ActiveDocument.Content.TEXT
>							THISFORM.oWord.documents.CLOSE()
>							*xNt=ALLTR(xNt,CHR(13)+CHR(10))
>							xNt=STRTRAN(xNt,CHR(13),[<br>])
>
>							TEXT TO lcHTML NOSHOW TEXTMERGE ADDITIVE
>							<tr><hr>
>							<<xNt>>
>							<hr></tr>
>							ENDTEXT
>						ENDIF
>						****
>
>					OTHERWISE
>
>				ENDCASE
>			ENDSCAN
>			TEXT TO lcHTML NOSHOW TEXTMERGE ADDITIVE
>				</table></body></html>
>			ENDTEXT
>			WITH THISFORM.oWB
>				.NAVIGATE("about:blank")
>				lnStartSeconds = SECONDS()
>				DO WHILE .ReadyState <> 4 ;
>						AND (SECONDS()-lnStartSeconds <= 1 )
>					DOEVENTS
>				ENDDO
>				.DOCUMENT.OPEN()
>				.DOCUMENT.WRITE(lchtml)
>				.DOCUMENT.CLOSE()
>				.VISIBLE=.T.
>			ENDWITH
>		ENDIF
>
>
>Thanks for your input
>
>
>Peter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform