Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Word as report writer from Access VBA - html files 1

Status
Not open for further replies.

Driep

MIS
Jul 11, 2003
11
ZA
Hi,

I wrote a little application that reads file names from a database table where it is linked to a 'Manual Doc Code' in a specific sequence.

I want to use Word as the report writer to print these fiels in the sequence that they are linked.

With .doc files this works perfectly using Word.Application and Word.Document objects.

However, when I try to print an .html file, I get the VBA error message: "Type Mismatch".

How can I tell VBA and Word.Application that it is ok to open and priont a .html file ?

I have tried FileConverters. Although I can save a file from within Word as a 'Web Page', VBA tells me that 'Web Page' is not a valid file converter.

Any help will be appreciated.

Phlip
 
I write a 'txt' file and open it in Word. Would that work for you?

rollie@bwsys.net
 
Hi,

Unfortunately not. The files that I want to print is system manual files that is published via a browser - therfore the .html

PPP
 
It is possible that it send out a warning about validation
you could try and switch the warning off
but I am not sure

Hope this helps
Hymn
 
Hi Hymn,

How do I turn the validation off ?

Driep
 
DoCmd.SetWarnings False
code
DoCmd.SetWarnings true

The more i look the more i wonder, was this code written for a previous version of access to your current version

Hope this helps
Hymn
 
Hi,

Didn't help. But thanks all the same.

Driep
 
Last time I had the error
However, when I try to print an .html file, I get the VBA error message: "Type Mismatch".
I hadn't declared recordset as DAO.recordset

How are you sending it?

DoCmd.OutputTo,acOutputReport, "Your Name",acFormatHTML




Hope this helps
Hymn
 
Here's an article that may help you.

Converting Word 97 Documents to HTML
John Clarkson
Microsoft Corporation

August 1999

Summary: This tip describes how to programmatically convert Word 97 documents to HTML files. (2 printed pages)

This tip describes how to programmatically convert Microsoft® Word 97 documents to HTML files. It's possible to come up with some quick-and-dirty code to do this by referring to the HTML member of the FileConverters collection, or by using the Save As HTML (File menu) command while recording a macro. However, both of these temporary solutions rely on settings that vary from machine to machine. You can't successfully port the code to a second machine without finding the values specific to the new environment and using these values to edit your code accordingly. To find a portable HTML conversion solution, you need code that loops through the FileConverters collection looking for the right converter. When the converter is found, use it as the value of the FileFormat argument of the SaveAs method, and exit the loop. The following procedure does just that.

Sub HTMLSave()
' This procedure steps through the FileConverters collection
' looking for the HTML converter, and then converts the current file.

Dim wrdConverter As FileConverter
Dim strMessage As String
Dim strPath As String

'Get a name and location for the converted file.
strMessage = "Enter a path and file name for the converted file."
strPath = InputBox(strMessage)

For Each wrdConverter In Word.FileConverters
'If found, Save As, then exit the loop.
If wrdConverter.ClassName = "HTML" Then
ActiveDocument.SaveAs _
FileName:=strPath, _
FileFormat:=wrdConverter.SaveFormat
Exit For
End If
Next wrdConverter
End Sub

Understand that there are limitations to any automated conversion. Note that if you use this solution:

Tables, fonts, and paragraph formatting are converted faithfully.


Graphic files are exported appropriately to the new HTML doc.


AutoShapes and WordArt are not converted.


Tabs are either ignored or converted to spaces (with no way to predict which will happen).

David
 
I was looking in help and I came across the code below
DoCmd.OutputTo acOutputReport, "YourReportName", acFormatHTML
which was written in my last thead on this with out the slight error
basicly create your report then output it as a .html

Hope this helps
Hymn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top