SaveToFile Method |
[Top] [Chapter] [Previous] [Next] |
Declaration bool SaveToFile([In] string filename, [In] bool OnlySelection, [In] string FormatStr); Description Save text to a file. The engine will determine the format using the extension - unless you specify it using a format string such as "RTF", "HTML", "ANSI", "UNICODE" or "MIME".
RTF2PDF/TextDynamic Server V4.23 and later can also load and save MS Word DocX files. TextDynamic 7 can load and save in this format if the DocX license had been activated.
This VB.NET example code display a file save dialog and saves the text in the editor:
Dim SaveFileDialog As New SaveFileDialog SaveFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments SaveFileDialog.Filter = "Textfiles (*.rtf,*.wpt,*.htm,*.html)|*.rtf;*.wpt;*.htm;*.html|All Files (*.*)|*.*"
If (SaveFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then Dim FileName As String = SaveFileDialog.FileName If Not WpdllInt1 Is Nothing Then Dim memo As WPDynamic.IWPMemo memo = WpdllInt1.Memo If Not memo.SaveToFile(FileName, False, "AUTO") Then MessageBox.Show("Cannot write " + FileName) End If End If End If If you want to send an HTML e-mail from Outlook You can use this VB code:
Dim olkApp As Outlook.Application, _ olkMsg As Outlook.MailItem, _ objFSO As FileSystemObject, _ objFile As TextStream
'Save File as HTML Dim Result As Boolean Dim sFilename As String
sFilename = "C:\xxxxx.htm" Result = Me.WPDLLInt0.memo.SaveToFile(sFilename, False, "HTML")
'Read the document in using the FileSystemObject Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(sFilename, 1, False) 'Get the open instance of Outlook Set olkApp = GetObject(, "Outlook.Application") 'Create a new message Set olkMsg = olkApp.CreateItem(0) 'Read the saved Word doc into the body of the message olkMsg.HTMLBody = objFile.ReadAll 'Display the message olkMsg.Display 'Destroy all the objects to avoid memory leaks Set olkMsg = Nothing objFile.Close Set objFile = Nothing Set objFSO = Nothing
Category |