Print HTML

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following code prints a .DOC file to the default printer without
prompting for a printer. I would like to do the same for an HTML file.
Unfortunately when I insert an HTM file in this code, I always get a prompt.
Is there a solution for HTM files?

myProcess.StartInfo.FileName = "D:\Temp\This is a test.doc"
myProcess.StartInfo.Verb = "PrintTo"
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.UseShellExecute = True
myProcess.Start()
If myProcess.Responding Then
myProcess.CloseMainWindow()
Else
myProcess.Kill()
End If
 
This is because Internet Explorer is the default application to open HTML
files. If you want to use Word to open and print HTML files, try this:
Dim psi As System.Diagnostics.ProcessStartInfo psi = new
System.Diagnostics.ProcessStartInfo()

psi.Arguments = "<path to html file> /mFilePrintDefault /mFileExit"

psi.FileName = "winword.exe"

psi.CreateNoWindow = True



System.Diagnostics.Process.Start(psi)

However, this visibly opens Word application to do the operation.

HTH

The following code prints a .DOC file to the default printer without
prompting for a printer. I would like to do the same for an HTML file.
Unfortunately when I insert an HTM file in this code, I always get a prompt.
Is there a solution for HTM files?

myProcess.StartInfo.FileName = "D:\Temp\This is a test.doc"
myProcess.StartInfo.Verb = "PrintTo"
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.UseShellExecute = True
myProcess.Start()
If myProcess.Responding Then
myProcess.CloseMainWindow()
Else
myProcess.Kill()
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top