-4

I am very new to Vb and I got faced with an issue when saving text from a text box into a word doc. The document saves fine wherever I want it to save but when I open it pops up with enter image description here

This is the code for the save

Private Sub BtnSave_Click(sender As Object, e As EventArgs) Handles BtnSave.Click
    Dim SaveDialog As New SaveFileDialog
    SaveDialog.Filter = "Word Document (*.docx)|*.docx|Word 97-2003 Document (*.doc)|*.doc|Plain Text (*.txt)|*.txt"
    SaveDialog.ShowDialog()
    If SaveDialog.FileName <> "" Then
        Dim writer As New StreamWriter(SaveDialog.FileName)
        writer.WriteLine(TxtPreviewcertificate.Text)
        writer.Close()
    End If
End Sub

End Class If anyone could help me with this please let me know, thanks.

MADTINGS
  • 1
  • 2
  • 3
    docx files are not simple text files. Save your file with txt extension – Steve Jul 15 '18 at 16:45
  • you could use interop...xml sdk...or other 3rd parties to create word docs...https://stackoverflow.com/questions/19656626/how-do-i-create-the-docx-document-with-microsoft-office-interop-word – Ctznkane525 Jul 15 '18 at 17:23

1 Answers1

-1

I changed it from .docx to doc

SaveDialog.Filter = "Word Document (*.docx)|*.docx|Word 97-2003 Document (*.doc)|*.doc|Plain Text (*.txt)|*.txt"
MADTINGS
  • 1
  • 2