Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Access to create HTML file for WORD

 
Goto page Previous  1, 2
   Database Help (Home) -> MS Access RSS
Next:  Datasheet View Column Order  
Author Message
Peter Jamieson

External


Since: Jan 01, 2009
Posts: 1



(Msg. 16) Posted: Thu Jan 01, 2009 11:32 am
Post subject: Re: Access to create HTML file for WORD [Login to view extended thread Info.]
Archived from groups: microsoft>public>access, others (more info?)

If you only need to target Word 2003 or later it might be better to emit
WordProcessingML text rather than RTF, particularly if the formatting
requirements are fairly simple. Although I wouldn't as it's particularly
easy to grasp how the style stuff works in WordProcessingML, you're more
likely to be able to re-use existing XML knowledge and XML-related tools.


Peter Jamieson

http://tips.pjmsn.me.uk

Petr Danes wrote:
> I'm looking at the RTF specs. Whew, they're complicated. Maybe if I
> generate my text once, then ask word to save it as an RTF file and
> examine the result, it will shed some light on the subject. I'll try
> that next.
>
> Yes, automation is the natural choice and is the first thing I tried. It
> worked, quite well in fact, but was simply too slow to be practical.
>
> I'm not sure I understand you regarding the template issue. I do have a
> custom template, in fact, it's stored in the database as a blob and
> written into the temp directory if it's not already there. Same with the
> CSS file. The intention was to make the database completely
> self-contained, that is, one-file portable. I know how to break the
> AttachedTemplate link from the document, but this sounds like there may
> be more. Is there some tie between a custom template and Normal.DOT? If
> so, what do I do about it?
>
> Pete
>
>
>
>
> "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
> píše v diskusním příspěvku
>> Sorry, but I've no idea why CSS/HTML is giving you so much trouble.
>> Personally, I don't use it for Word and I would probably use
>> Automation if I ever had to create a Word document. However, as this
>> solution seems to be to slow in your case, suggesting to take a look
>> at the RTF format seems to be a promising path.
>>
>> I've also noticed that you are using a template to create your new
>> document and that this document is probably using the standard
>> Normal.DOT file for its basic formatting. Maybe one of these is the
>> source of your problem.
>>
>> --
>> Sylvain Lafontaine, ing.
>> MVP - Technologies Virtual-PC
>> E-mail: sylvain aei ca (fill the blanks, no spam please)
>>
>>
>> "Petr Danes" wrote in message
>>
>>> Hm, hadn't thought of the RTF path. I'll have to study the specs and
>>> see if it can do everything I need. It looks promising, I had no idea
>>> that RTF was such a capable format. Including all the formatting
>>> inline may bulk the file a bit, but I'll give it a try.
>>>
>>> Still, the CSS/HTML route should work as well. Any ideas why it's
>>> giving me so much trouble?
>>>
>>> As for the Range.InsertFile, I forget now exactly why I did it that
>>> way, rather than simply opening a file, but there was a reason. I
>>> think maybe it was because the Open command opens a new document each
>>> time it is called, causing them to pile up when doing multiple searches.
>>>
>>>
>>>
>>> "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam
>>> please)> píše v diskusním příspěvku
>>>
>>>> Instead of using Range.InsertFile, maybe you should open the HTML
>>>> document as an independant word document and then transfert it to
>>>> the real document. For an example, see:
>>>>
>>>> http://www.bokebb.com/dev/english/1990/posts/199082985.shtml
>>>>
>>>> Also, this example is about using a RTF document instead of using
>>>> HTML; maybe you should do the same and use RTF instead of HTML. I
>>>> won't be surprisde if you have a better control over your RTF
>>>> documents than over an HTML document.
>>>>
>>>> References on RTF:
>>>>
>>>> http://en.wikipedia.org/wiki/Rich_Text_Format
>>>>
>>>> http://www.microsoft.com/downloadS/details.aspx?familyid=DD422B8D-FF06...07-B476
>>>>
>>>>
>>>> http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txt...eId=692
>>>>
>>>>
>>>> --
>>>> Sylvain Lafontaine, ing.
>>>> MVP - Technologies Virtual-PC
>>>> E-mail: sylvain aei ca (fill the blanks, no spam please)
>>>>
>>>>
>>>> "Petr Danes" wrote in message
>>>>
>>>>> Does anyone have any experience with loading a document -INTO-Word
>>>>> using HTML and a cascading style sheet? All the stuff I have found
>>>>> in the archives deals with exporting Word docs to HTML - I want to
>>>>> do the opposite.
>>>>>
>>>>> I have an ACCESS database that does lookups and uses VBA to create
>>>>> a Word document detailing the results. Initially, I had the
>>>>> database using a Word template to create the document, but the
>>>>> process was too slow to be useful, so I converted it to write out
>>>>> plain text HTML, with references to a cascading style sheet. The
>>>>> results are mixed. Speed is much improved, but Word's use of the
>>>>> styles I define in the CSS are hit and miss. A sample few lines of
>>>>> the generated HTML text and the entire style sheet are reproduced
>>>>> at the end of this post.
>>>>>
>>>>> The basic definition, the first style, named QuarxZakladOdstavec
>>>>> does not appear at all in the created Word document, unless I add
>>>>> some unnecessary text specifically using that style. The subsequent
>>>>> definitions, which I would like to be based on this first one are
>>>>> not, but are based on Normal. Some of the graphic definitions,
>>>>> specifically margins, seem to be ignored completely. The styles are
>>>>> affected by whatever styles are already present in Word, in fact,
>>>>> they seem to take precedence over those defined in the CSS file,
>>>>> and I have to run some VBA code which deletes all 'Quarx' styles
>>>>> before some changes take effect. (But not all, some CSS styles do
>>>>> take effect next time the HTML file is loaded, even if the old
>>>>> style remains.) The Access code opens a Word template, which uses
>>>>> this line to load the HTML file:
>>>>> doc.Range.InsertFile FileName:="abc.htm"
>>>>> if that makes any difference.
>>>>>
>>>>> Word is capable of creating this stuff from its native files as
>>>>> well as reading files in this and other formats, but my results
>>>>> seem almost random. If anyone can shed some light on this, or maybe
>>>>> even suggest a different approach altogether, I'd appreciate some
>>>>> thoughts.
>>>>>
>>>>> Pete
>>>>>
>>>>>
>>>>>
>>>>> =====================================================
>>>>> Beginning of generated HTML text file:
>>>>>
>>>>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>>>>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>>>>> <head>
>>>>> <title>Class and ID Selectors</title>
>>>>> <meta http-equiv="Content-Type"
>>>>> content="text/xhtml;charset=windows-1250"/>
>>>>> <link rel='stylesheet' type='text/css' href='C:\Users\Petr
>>>>> Danes\AppData\Local\Temp\QuarxStylesheet 2008-12-16_14-29-12.css'/>
>>>>> </head>
>>>>> <body >
>>>>> <p class='QuarxZakladOdstavec'>
>>>>> ABCEDFG
>>>>> <p class='QuarxHS'>
>>>>> ._HS Gottaischer&#x0009;[C:\Palma\T602\Hyper\A
>>>>> test\BATEL\BATELOV.TXT] {001}
>>>>> </p>
>>>>> <p class='QuarxPovel'>
>>>>> .AU
>>>>> </p>
>>>>> <p class='QuarxAutor'>
>>>>> Gottaischer
>>>>> </p>
>>>>> <p class='QuarxPovel'>
>>>>> .TI
>>>>> </p>
>>>>> <p class='QuarxObycejnyText'>
>>>>> Gottaischer Hofkalender fuer 1779, 1780.
>>>>> </p>
>>>>> <p class='QuarxPovel'>
>>>>> .IM
>>>>> </p>
>>>>> <p class='QuarxObycejnyText'>
>>>>> Goth a, s. t., 1779, 1780, 110, 175 s., 8´.
>>>>> </p>
>>>>> <p class='QuarxPovel'>
>>>>> .RO
>>>>> </p>
>>>>> <p class='QuarxObycejnyText'>
>>>>>
>>>>> </p>
>>>>> <p class='QuarxPovel'>
>>>>>
>>>>> <!--
>>>>>
>>>>>
>>>>>
>>>>> Entire CSS file
>>>>>
>>>>> /* Style Definitions */
>>>>>
>>>>> /* Tohle je základ pro všechny další styly, použité pro různá
>>>>> označení */
>>>>>
>>>>> p.QuarxZakladOdstavec
>>>>> {mso-style-name:QuarxZakladOdstavec;
>>>>> mso-style-parent:"Normal";
>>>>> mso-pagination:widow-orphan;
>>>>> font-size:12.0pt;
>>>>> margin-top:0pt;
>>>>> margin-bottom:0pt;
>>>>> font-family:"Courier New";}
>>>>>
>>>>> /* Autor, signatura a datum jsou speciálně označené, aby byly
>>>>> rychle vidět */
>>>>>
>>>>> p.QuarxAutor
>>>>> {mso-style-name:QuarxAutor;
>>>>> mso-style-parent:QuarxZakladOdstavec;
>>>>> font-size:12.0pt;
>>>>> margin-top:0pt;
>>>>> margin-bottom:0pt;
>>>>> color:red;
>>>>> font-weight:bold;}
>>>>> p.QuarxSignatura
>>>>> {mso-style-name:QuarxSignatura;
>>>>> mso-style-parent:QuarxZakladOdstavec;
>>>>> color:blue;
>>>>> font-weight:bold;}
>>>>> p.QuarxDatum
>>>>> {mso-style-name:QuarxDatum;
>>>>> mso-style-parent:QuarxZakladOdstavec;
>>>>> color:#44BB44;
>>>>> font-weight:bold;
>>>>> text-decoration:underline;
>>>>> text-underline:single;}
>>>>> p.QuarxProvenience
>>>>> {mso-style-name:QuarxProvenience;
>>>>> mso-style-parent:QuarxZakladOdstavec;
>>>>> font-size:12.0pt;
>>>>> margin-top:0pt;
>>>>> margin-bottom:0pt;
>>>>> font-weight:bold;}
>>>>>
>>>>> /* Záhlaví, označené pomocí ._HS, je barvené podle toho, jestli
>>>>> heslo obsahuje nebo neobsahuje hledaný text */
>>>>>
>>>>> p.QuarxHS
>>>>> {mso-style-name:QuarxHS;
>>>>> mso-style-parent:QuarxZakladOdstavec;
>>>>> mso-style-next:QuarxZakladOdstavec;
>>>>> page-break-before:always;
>>>>> mso-border-top-alt:solid black 0.5pt;
>>>>> tab-stops:right 468.0pt;
>>>>> font-size:8.0pt;
>>>>> margin-top:0pt;
>>>>> margin-bottom:0pt;
>>>>> color:#999999;}
>>>>>
>>>>>
>>>>> /* Tečkové povely jsou označené tady */
>>>>>
>>>>> p.QuarxPovel
>>>>> {mso-style-name:QuarxPovel;
>>>>> mso-style-parent:QuarxZakladOdstavec;
>>>>> mso-style-next:QuarxZakladOdstavec;
>>>>> font-size:8.0pt;
>>>>> margin-top:0pt;
>>>>> margin-bottom:0pt;
>>>>> color:#33CCCC;
>>>>> display:none;
>>>>> mso-hide:all;}
>>>>>
>>>>>
>>>>> /* Tečkové povely jsou označené tady */
>>>>> p.QuarxObycejnyText
>>>>> {mso-style-name:QuarxObycejnyText;
>>>>> mso-style-parent:QuarxZakladOdstavec;
>>>>> mso-style-next:QuarxPovel;
>>>>> font-size:12.0pt;
>>>>> margin-top:0pt;
>>>>> margin-right:0pt;
>>>>> margin-left:1.0cm;
>>>>> margin-bottom:0pt;
>>>>> font-family:"Courier New";}
>>>>>
>>>>>
>>>>> /* Tady je speciální označení nalezeného textu */
>>>>>
>>>>> span.QuarxFound
>>>>> {mso-style-name:QuarxFound;
>>>>> background:pink;}
>>>>>
>>>>> span.QuarxNalezenyText
>>>>> {mso-style-name:QuarxNalezenyText;
>>>>> background:yellow;
>>>>> border:1px solid lime;}
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> This e-mail address is fake, to keep spammers and their address
>>>>> harvesters out
>>>>> of my hair. If you want to get in touch personally, I am 'pdanes'
>>>>> and I use
>>>>> yahoo mail. But please use the newsgroup when possible, so that all
>>>>> may
>>>>> benefit from the exchange of ideas.
>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>

 >> Stay informed about: Access to create HTML file for WORD 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Can Access create Word documents? - Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE....

Merged records to Word from Access-Create page break based.. - I have merged the data from Access. Now I need Word to start a new page every time the sequence number changes. How is this accomplished? Also, is it possible to tell Word to hide duplicates? On some pages, the Owner will have multiple accounts. I d...

pulling data from ACCESS to html file via vbscript - Hi everyone can someone can give me a code sample of vbscript that presenting ACCESS database on html without usaghe of DSN

html tags in report OR image url to display in exported ht.. - Hi, I have a data base. One field contains an image url e.g. http://www.zionmusiccenter.com/catalog/as224ps-f.jpg I would like to be able to create from each record of my database an html page. In this page, I would like to show the abovementioned..

Req help: How do I open a MS Word file from Access? - Hi all, I created a button in an Access form that opens MS Word. Now I want this button also to open a specific file. How do I code this? Would it also be possible to let the user select the type of template from a list? It would be perfect if this..
   Database Help (Home) -> MS Access All times are: Pacific Time (US & Canada)
Goto page Previous  1, 2
Page 2 of 2

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]