how save data in msword through vb6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rinku123
    New Member
    • Mar 2007
    • 10

    how save data in msword through vb6

    suppose in vb form are more then one textbox which is contain data and i want i click command button it save in msword file and it can replace many times suppose just like we make report).

    i have no experience about it i seen a exe file of vb6.
    which contain a msword file in this file some label & textbox control is placed
    i dont know how is it.

    and when i press commnd button which is in vb6 form. its data display i msword file Label and Textbox control.

    so plz help me.
    and give me full process or guidliness.
    or code which can i use o how to save ms word file with controls.
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Greetings and salutations, rinku123!

    You can do this in two ways:

    (1) You can add data through your VB form and save as .doc. That'll give you an MS Word file (provided you have MS Office installed)

    (2) You can add data through your VB form
    -Built an MS Access Database
    -Add data to it
    -Add DataReport/Data Environment in VB
    -Run a report
    Again, provided you have MS Office installed

    That should get you going.

    I would choose choice one, just to see what happens, then go crazy and add an Access database just for fun :-)

    It's exciting either way...

    Dököll

    Comment

    • rinku123
      New Member
      • Mar 2007
      • 10

      #3
      anybody if can help
      then plz help me.
      thanks lots

      Comment

      • rinku123
        New Member
        • Mar 2007
        • 10

        #4
        plz help me soon

        Comment

        • Dököll
          Recognized Expert Top Contributor
          • Nov 2006
          • 2379

          #5
          Did you try option # 1?

          What this means is, if you name the file being saved as myfile.doc you will ten have a document saved in word...

          Comment

          • Dököll
            Recognized Expert Top Contributor
            • Nov 2006
            • 2379

            #6
            Also, rinku123, you have not yet posted any of your code. Do you have anything running?

            Dököll

            Comment

            • keeaun
              New Member
              • Apr 2007
              • 2

              #7
              guys,

              below is my code to save the data in notepad
              can anyone pls teach me how to autosave cos this code there will be a pop up window for saving..
              thanks a lot.

              Code:
              Dim array_data As String
              Dim x As Integer
              Dim list_array As Variant
              
              List1.Clear
              array_data = "yes"
              
              CommonDialog1.CancelError = True
              On Error GoTo CancelButton
              CommonDialog1.Filter = "Text files (*.txt|*.txt"
              CommonDialog1.ShowSave
              Newfile = CommonDialog1.FileName
              
              Open Newfile For Output As #1
              
              If array_data <> "" Then
                  ReDim Preserve received_data(Text3.Text)
                  For x = 0 To Text3.Text
                  received_data(x) = x & "," & array_data
                  Next x
                  End If
              
              For Each list_array In received_data
                  Write #1, list_array
                  List1.AddItem List1.Text & vbCrLf & list_array
              Next
              
              Close #1
              
              CancelButton:
              Exit Sub
              Last edited by Killer42; Apr 8 '07, 03:04 AM. Reason: Please use [CODE]...[/CODE] tags around your code.

              Comment

              • Dököll
                Recognized Expert Top Contributor
                • Nov 2006
                • 2379

                #8
                Originally posted by keeaun
                guys,

                below is my code to save the data in notepad
                can anyone pls teach me how to autosave cos this code there will be a pop up window for saving..
                thanks a lot.

                Dim array_data As String
                Dim x As Integer
                Dim list_array As Variant

                List1.Clear
                array_data = "yes"

                CommonDialog1.C ancelError = True
                On Error GoTo CancelButton
                CommonDialog1.F ilter = "Text files (*.txt|*.txt"
                CommonDialog1.S howSave
                Newfile = CommonDialog1.F ileName

                Open Newfile For Output As #1

                If array_data <> "" Then
                ReDim Preserve received_data(T ext3.Text)
                For x = 0 To Text3.Text
                received_data(x ) = x & "," & array_data
                Next x
                End If

                For Each list_array In received_data
                Write #1, list_array
                List1.AddItem List1.Text & vbCrLf & list_array
                Next

                Close #1

                CancelButton:
                Exit Sub
                It is very likely you do not need this here:

                Code:
                CommonDialog1.CancelError = True
                On Error GoTo CancelButton
                CommonDialog1.Filter = "Text files (*.txt|*.txt"
                CommonDialog1.ShowSave
                Newfile = CommonDialog1.FileName
                Above deals with your dialog box, which you do not need. Could you do me a bg favour and delete the lines one by one, then run your code. I cannnot try this as of now:

                (1) Delete "CommonDialog1. CancelError = True", then run code
                (2) Delete "On Error GoTo CancelButton" then run code
                (3) If code runs fine, delete:

                CommonDialog1.F ilter = "Text files (*.txt|*.txt"
                CommonDialog1.S howSave

                (4) Lastly, delete "Newfile = CommonDialog1.F ileName", only if pop up nop longer come up.

                Anyone, please assist keeaun, I must run and cannot run this as of now. keeaun, please save this project before you do what I suggested, but I would delete the dialog data if I did not want to get a pop up before saving.

                In a bit!

                Dököll

                Comment

                Working...