• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

Sending a txt file to another program

If i have a text box with html code in it how could i go about useing a command button to post that text to the registered html viewer for the system so that i could view the rendered output for the html.
0
hess
Asked:
hess
1 Solution
 
Answers2000Commented:
Write the text in to a file with extension .HTM or .HTML then simply run the file.  You can do this using the ShellExecute API
0
 
hessAuthor Commented:
Sorry to reject your answer but i don't know how to use the shell api so if you could write some code for me the points are yours.
0
 
dokkenCommented:
This works...

Create a module and put this in it(all on one line):

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Add this to your form code and modify it as needed:

Private Sub command1_Click()

       Open "temp.htm" For Output As #1
       Print #1, Text1.Text
       Close #1
       iRet = ShellExecute(Me.hwnd, vbNullString, "file://temp.htm", vbNullString, "c:\", SW_SHOWNORMAL)
       Exit Sub

End Sub

thats all there is to it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now