Solved

Sending a txt file to another program

Posted on 1998-08-13
3
149 Views
Last Modified: 2010-04-30
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
Comment
Question by:hess
3 Comments
 
LVL 8

Expert Comment

by:Answers2000
ID: 1468763
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
 

Author Comment

by:hess
ID: 1468764
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
 

Accepted Solution

by:
dokken earned 30 total points
ID: 1468765
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now