0

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).

3
Contributors
13
Replies
73
Views
3 Years
Discussion Span
Last Post by missy_mi
Featured Replies
  • 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 Read More

  • 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 & … Read More

  • 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 Read More

0
    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
0

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

0

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

1

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
0

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.

0

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?

0

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)

0

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..

1

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)
0

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..

1

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.