• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 176
  • 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.
1 Solution
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
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.
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.
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

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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