Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. word document [modified]

word document [modified]

Scheduled Pinned Locked Moved Visual Basic
csharpasp-nettutorial
7 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hsuresh
    wrote on last edited by
    #1

    I am developing ASP.NET Web Application using vb.net One of the requriement of this application is ...when user submit the Web Form....it should open the Word Templete and insert the values into that templete... Does anybody knows...How to Open and Writes into Word Document Using ASP.NET and vb.net Directly...i am looking for specific sample... Thanks, -- modified at 8:43 Wednesday 4th July, 2007

    K 1 Reply Last reply
    0
    • H hsuresh

      I am developing ASP.NET Web Application using vb.net One of the requriement of this application is ...when user submit the Web Form....it should open the Word Templete and insert the values into that templete... Does anybody knows...How to Open and Writes into Word Document Using ASP.NET and vb.net Directly...i am looking for specific sample... Thanks, -- modified at 8:43 Wednesday 4th July, 2007

      K Offline
      K Offline
      koolprasad2003
      wrote on last edited by
      #2

      hello frnd, do u want to open the already saved file if yes try the following first add the COM reference, if you have word 2000 then add microsoft word object library 9.0 and if you have word 2003 then do add microsoft word object library 11.0 and then code as, imports word = microsoft.office.interop.word dim objApp as new word.application dim objDoc as new word.document objDoc = objApp.documents.open("\\Address Of Blank Word File") objdoc.visible = true and after writing content to file the user close the file By this code ; Already stored file open and displayed AND If you want to open the new file then dim objApp as new word.application dim objDoc as new word.document objDoc = objApp.documents.add("\\Address Of Blank Word File where u want to create") objdoc.visible = true in both the case the user must write and save the document regards, koolprasad2003:)

      If the message is useful for U then please Rate This message... Be a good listener...Because Opprtunity knoughts softly...N-Joy

      H 1 Reply Last reply
      0
      • K koolprasad2003

        hello frnd, do u want to open the already saved file if yes try the following first add the COM reference, if you have word 2000 then add microsoft word object library 9.0 and if you have word 2003 then do add microsoft word object library 11.0 and then code as, imports word = microsoft.office.interop.word dim objApp as new word.application dim objDoc as new word.document objDoc = objApp.documents.open("\\Address Of Blank Word File") objdoc.visible = true and after writing content to file the user close the file By this code ; Already stored file open and displayed AND If you want to open the new file then dim objApp as new word.application dim objDoc as new word.document objDoc = objApp.documents.add("\\Address Of Blank Word File where u want to create") objdoc.visible = true in both the case the user must write and save the document regards, koolprasad2003:)

        If the message is useful for U then please Rate This message... Be a good listener...Because Opprtunity knoughts softly...N-Joy

        H Offline
        H Offline
        hsuresh
        wrote on last edited by
        #3

        Ours is a web application and we get the error....."Message filter indicates that the application is busy..." Please help...we need this urgently Thanks, Suresh

        K 1 Reply Last reply
        0
        • H hsuresh

          Ours is a web application and we get the error....."Message filter indicates that the application is busy..." Please help...we need this urgently Thanks, Suresh

          K Offline
          K Offline
          koolprasad2003
          wrote on last edited by
          #4

          have you tried what i told.... working with word automation is easy... regards, koolprasad2003:) Be a good listener...Because Opprtunity knoughts softly...N-Joy

          H 1 Reply Last reply
          0
          • K koolprasad2003

            have you tried what i told.... working with word automation is easy... regards, koolprasad2003:) Be a good listener...Because Opprtunity knoughts softly...N-Joy

            H Offline
            H Offline
            hsuresh
            wrote on last edited by
            #5

            this is our code.... It works in a windows application but not in a web application....please try it out and help.. Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(336, 176) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(576, 470) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Dim wrdApp As Word.Application Dim wrdDoc As Word._Document Private Sub InsertLines(ByVal LineNum As Integer) Dim iCount As Integer ' Insert "LineNum" blank lines. For iCount = 1 To LineNum wrdApp.Selection.TypeParagraph() Next iCount End Sub Private Sub FillRow(ByVal Doc As Word.Document, ByVal Row As Integer, _ ByVal Text1 As String, ByVal Text2 As String, _ ByVal Text3 As String, ByVal Text4 As String) With Doc.Tables.Item(1) ' Insert the data in the specific cell.

            K 1 Reply Last reply
            0
            • H hsuresh

              this is our code.... It works in a windows application but not in a web application....please try it out and help.. Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(336, 176) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(576, 470) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Dim wrdApp As Word.Application Dim wrdDoc As Word._Document Private Sub InsertLines(ByVal LineNum As Integer) Dim iCount As Integer ' Insert "LineNum" blank lines. For iCount = 1 To LineNum wrdApp.Selection.TypeParagraph() Next iCount End Sub Private Sub FillRow(ByVal Doc As Word.Document, ByVal Row As Integer, _ ByVal Text1 As String, ByVal Text2 As String, _ ByVal Text3 As String, ByVal Text4 As String) With Doc.Tables.Item(1) ' Insert the data in the specific cell.

              K Offline
              K Offline
              koolprasad2003
              wrote on last edited by
              #6

              Dear Suresh, let me suggest U a simplest and finest way, open a word file, record a macro and do the events u wants, and stop the macro and Press Alt+F11 copy the code in VB Project and open that project using .Net it will gives you a code.. regards, koolprasad2003:)

              If the message is useful for U then please Rate This message... Be a good listener...Because Opprtunity knoughts softly...N-Joy

              H 1 Reply Last reply
              0
              • K koolprasad2003

                Dear Suresh, let me suggest U a simplest and finest way, open a word file, record a macro and do the events u wants, and stop the macro and Press Alt+F11 copy the code in VB Project and open that project using .Net it will gives you a code.. regards, koolprasad2003:)

                If the message is useful for U then please Rate This message... Be a good listener...Because Opprtunity knoughts softly...N-Joy

                H Offline
                H Offline
                hsuresh
                wrote on last edited by
                #7

                i worked with macros also it's not working can please help me. if u have code for creating word document. Dim w As New Word.Application Dim d As Word.Document d = w.Documents.Open("c:\test1.doc") 'w.Selection.MoveRight(Unit:=1, count:=6) d.MailMerge.OpenDataSource(Name:="C:\test1.csv", ReadOnly:=False, LinkToSource:=True, Connection:="", SQLStatement:="", SQLStatement1:="") d.Fields.Add(Range:=w.Selection.Range, Type:=Word.WdFieldType.wdFieldMergeField, Text:="""LastName""") With d.MailMerge .Destination = Word.WdMailMergeDestination.wdSendToNewDocument .SuppressBlankLines = True With .DataSource .FirstRecord = Word.WdMailMergeDefaultRecord.wdDefaultFirstRecord .LastRecord = Word.WdMailMergeDefaultRecord.wdDefaultLastRecord End With .Execute(Pause:=False) End With w.Visible = True

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups