Hello..

good day evryone, i encounter a problem with my save as form..i use savefiledialog..the result is that the page is saved..but when i open the word doc, it is empty..there is no data whatsoever..

i dont use database..it is suppose to save the the data that i filled in my form but no data was save in the document(word aplication).

Hi Post some of your code and we can see where it is going wrong...

    Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveAsToolStripMenuItem.Click
        'it is running with no error but the word document is empty.
        SaveFileDialog1.FileName = "untitled"
        SaveFileDialog1.Filter = "Word(.docx)|*.docx"
        SaveFileDialog1.RestoreDirectory = True
        Me.SaveFileDialog1.ShowDialog()
        If (SaveFileDialog1.FilterIndex = 2) Then
            SaveFileDialog1.OpenFile()
        End If

Exactly! your code will create an empty word file. you need to add your data to the MS word file programmatically

hehe..(feel so stupid)..hee..i guess it..but, i dont know how..do know any good links.. ^^

try this

Imports Microsoft.Office.Interop.Word

wordapp = New Word.Application
worddoc = New Word.Document
    'create word file
worddoc = wordapp.Documents.Add()
worddoc.Activate()
    'save data
wordapp.Selection.TypeText("YOUR DATA")
    'save as
wordapp.Dialogs(WdWordDialog.wdDialogFileSaveAs).Show()
    'close app
worddoc.Close()
wordapp.Quit()
worddoc = Nothing
wordapp = Nothing

i tried this

dim wordapp As Word.Application
dim worddoc As word.Document

worddoc = wordapp.Documents.Add()
worddoc.Activate()
wordapp.Selection.TypeText("YOUR DATA")
wordapp.Dialogs(wdWordDialog.wdDialogFileSaveAs).Show()
worddoc.Close()
wordapp.Quit()

worddoc = Nothing
wordapp = Nothing

i couldn't save anything..there is a warning : Varible 'wordapp' is used before it has been assigned a value. A null reference exception could result at runtime.

opss..my bad..its

dim wordapp As New Word.Application
dim worddoc As New word.Document

worddoc = wordapp.Documents.Add()
worddoc.Activate()
wordapp.Selection.TypeText("YOUR DATA")
wordapp.Dialogs(wdWordDialog.wdDialogFileSaveAs).Show()
worddoc.Close()
wordapp.Quit()

worddoc = Nothing
wordapp = Nothing

Now..its wordking..Thank you so much..but, what if i wanted to save my form..i mean, like typical registration form to save as word..when i ahve already filled in the form..is it possible for me to get everything on the word page??or i need to do hard coding of the form?? or can i just capture the form page?

by data i mean plain text,now the question is where do your write your data, textbox or richtextbox? if so
wordapp.Selection.TypeText(textbox)
or
wordapp.Selection.TypeText(richtextbox)

Thank you..its not just plain text..its the whole form page..example : Click Here..is there a way??links??tutorials??anything that can be usefull??..

thank you so much..

im assuming your "textbox"s are named textbox1 and textbox2 and so on..

dim wordData as string
wordData = "Login : " & textbox1.text & vbnewline &_
"First Name : " & textbox2.text & vbnewline &_
"Last Name : " & textbox3.text & vbnewline &_
"Password : " & textbox4.text & vbnewline &_
"Email : " & textbox5.text & vbnewline &_
"Content Lang : " & Combobox1.text & vbnewline &_
"interface Lang : " & Combobox2.text

wordapp.Selection.TypeText(wordData)

Alright..Thanks a lot..i appreciate your help..Actually, i was hoping that i wouldn't have to code everything one by one..because there is lots of data, in the form..the one with the links above, is just an example..But thanks anyway..

Is there a more convienient way??..
thank you..

hmm dont know about that...actually if you use a datagridview itll be less coding for you other than that u gonna have to code everything
gd luck

hmm..Okay.Thank you..Thank you..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.