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
  1. Home
  2. General Programming
  3. Visual Basic
  4. word document in web application

word document in web application

Scheduled Pinned Locked Moved Visual Basic
csharphelp
5 Posts 4 Posters 0 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.
  • M Offline
    M Offline
    Manik Nath
    wrote on last edited by
    #1

    hi all, i'm developin a web application in vb.net 2005 in which i need certain values to be passed to a word document....but i'm unable to do so....can anyone here help me... Any help will be very kind of you Thanks..

    R H 2 Replies Last reply
    0
    • M Manik Nath

      hi all, i'm developin a web application in vb.net 2005 in which i need certain values to be passed to a word document....but i'm unable to do so....can anyone here help me... Any help will be very kind of you Thanks..

      R Offline
      R Offline
      Rizwan Bashir
      wrote on last edited by
      #2

      this is the function I am using by passing datatable and filename Private Sub SaveDataToMSWord(ByVal dt As DataTable, ByVal FileName As String) Try Dim oldCI As System.Globalization.CultureInfo = _ System.Threading.Thread.CurrentThread.CurrentCulture System.Threading.Thread.CurrentThread.CurrentCulture = _ New System.Globalization.CultureInfo("en-US") Dim wapp As Word.Application Dim wdoc As Word.Document ' Dim strDbFullPath As String Dim strText As String wapp = New Word.Application wapp.Visible = True wdoc = wapp.Documents.Add Dim Count As Integer = 0 For Count = 0 To dt.Rows.Count - 1 Dim strDesignation As String = dt.Rows(Count).Item("ConJobTitleManual") If strDesignation = "" Then strDesignation = dt.Rows(Count).Item("Others") End If strText = dt.Rows(Count).Item("cpyName") With (wapp.Selection) .Font.Size = 14 .Font.Color = Word.WdColor.wdColorBlack .Font.Bold = True .TypeText(strText) .InsertBreak(Type:=Word.WdBreakType.wdLineBreak) .Font.Size = 9 .Font.Bold = False .TypeText(dt.Rows(Count).Item("cpyAddress1") & "," & dt.Rows(Count).Item("cpyTown") & "," & dt.Rows(Count).Item("cpyCounty") & "," & dt.Rows(Count).Item("cpyPostCode")) .InsertBreak(Type:=Word.WdBreakType.wdLineBreak) .TypeText(dt.Rows(Count).Item("cpyCountry")) .InsertBreak(Type:=Word.WdBreakType.wdLineBreak) If dt.Rows(Count).Item("cpySIC1") <> 0 Then .TypeText("SIC:" & dt.Rows(Count).Item("cpySIC1")) If dt.Rows(Count).Item("cpySIC2") <> 0 Then .TypeText("," & dt.Rows(Count).Item("cpySIC2")) End If End If .InsertBreak(Type:=Word.WdBreakType.wdLineBreak) .TypeText(dt.Rows(Count).Item("cpyURL")) .InsertBreak(Type:=Word.WdBreakType.wdLineBreak) .TypeText("Tel:" & dt.Rows(Count).Item("ConTelMain")) .InsertBreak(Type:=Word.WdBreakType.wdLineBreak) End With

      M 1 Reply Last reply
      0
      • R Rizwan Bashir

        this is the function I am using by passing datatable and filename Private Sub SaveDataToMSWord(ByVal dt As DataTable, ByVal FileName As String) Try Dim oldCI As System.Globalization.CultureInfo = _ System.Threading.Thread.CurrentThread.CurrentCulture System.Threading.Thread.CurrentThread.CurrentCulture = _ New System.Globalization.CultureInfo("en-US") Dim wapp As Word.Application Dim wdoc As Word.Document ' Dim strDbFullPath As String Dim strText As String wapp = New Word.Application wapp.Visible = True wdoc = wapp.Documents.Add Dim Count As Integer = 0 For Count = 0 To dt.Rows.Count - 1 Dim strDesignation As String = dt.Rows(Count).Item("ConJobTitleManual") If strDesignation = "" Then strDesignation = dt.Rows(Count).Item("Others") End If strText = dt.Rows(Count).Item("cpyName") With (wapp.Selection) .Font.Size = 14 .Font.Color = Word.WdColor.wdColorBlack .Font.Bold = True .TypeText(strText) .InsertBreak(Type:=Word.WdBreakType.wdLineBreak) .Font.Size = 9 .Font.Bold = False .TypeText(dt.Rows(Count).Item("cpyAddress1") & "," & dt.Rows(Count).Item("cpyTown") & "," & dt.Rows(Count).Item("cpyCounty") & "," & dt.Rows(Count).Item("cpyPostCode")) .InsertBreak(Type:=Word.WdBreakType.wdLineBreak) .TypeText(dt.Rows(Count).Item("cpyCountry")) .InsertBreak(Type:=Word.WdBreakType.wdLineBreak) If dt.Rows(Count).Item("cpySIC1") <> 0 Then .TypeText("SIC:" & dt.Rows(Count).Item("cpySIC1")) If dt.Rows(Count).Item("cpySIC2") <> 0 Then .TypeText("," & dt.Rows(Count).Item("cpySIC2")) End If End If .InsertBreak(Type:=Word.WdBreakType.wdLineBreak) .TypeText(dt.Rows(Count).Item("cpyURL")) .InsertBreak(Type:=Word.WdBreakType.wdLineBreak) .TypeText("Tel:" & dt.Rows(Count).Item("ConTelMain")) .InsertBreak(Type:=Word.WdBreakType.wdLineBreak) End With

        M Offline
        M Offline
        Manik Nath
        wrote on last edited by
        #3

        Thanx rizwan for your help.....but this code works in windows application not in web application...anyways i got a way to get it in web application, but now i have another problem, i have a datagrid in the same application now i want to get that data grid in the word document....can you help me on this..... thanks a lot rizwan manik

        U 1 Reply Last reply
        0
        • M Manik Nath

          Thanx rizwan for your help.....but this code works in windows application not in web application...anyways i got a way to get it in web application, but now i have another problem, i have a datagrid in the same application now i want to get that data grid in the word document....can you help me on this..... thanks a lot rizwan manik

          U Offline
          U Offline
          User 2269706
          wrote on last edited by
          #4

          Hi Friend, i need a small help I want to displya the word document on the web form with out changing the formate ie ., i need some control with in which i can display the word document in the server Thanks in Advance

          1 Reply Last reply
          0
          • M Manik Nath

            hi all, i'm developin a web application in vb.net 2005 in which i need certain values to be passed to a word document....but i'm unable to do so....can anyone here help me... Any help will be very kind of you Thanks..

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

            if u add reference office 11 object library then..you can open word.

            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