Solved

Sending a txt file to another program

Posted on 1998-08-13
3
148 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

705 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

13 Experts available now in Live!

Get 1:1 Help Now