Click here to Skip to main content
15,923,142 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to replace null(00) character instead of space(20)? Pin
Christian Graus11-Jul-06 1:21
protectorChristian Graus11-Jul-06 1:21 
GeneralRe: How to replace null(00) character instead of space(20)? Pin
eddie.jiang.tw11-Jul-06 22:40
eddie.jiang.tw11-Jul-06 22:40 
Questionthis is how u have to create ODBC , DSN using vb script Pin
Member 227165510-Jul-06 22:34
Member 227165510-Jul-06 22:34 
QuestionExport to WOrd Pin
Socheat.Net10-Jul-06 22:02
Socheat.Net10-Jul-06 22:02 
AnswerRe: Export to WOrd Pin
Member 227165511-Jul-06 1:02
Member 227165511-Jul-06 1:02 
QuestionRichTextBox Pin
Socheat.Net10-Jul-06 22:00
Socheat.Net10-Jul-06 22:00 
Questionword document in web application Pin
Manik Nath10-Jul-06 20:42
Manik Nath10-Jul-06 20:42 
AnswerRe: word document in web application Pin
Rizwan Bashir10-Jul-06 22:52
Rizwan Bashir10-Jul-06 22:52 
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
Dim counter As Integer = Count
For counter = Count To dt.Rows.Count - 1
If dt.Rows(counter).Item("cpyName") = dt.Rows(Count).Item("cpyName") Then
strText = strDesignation & vbTab & dt.Rows(counter).Item("conEmail") & vbTab & vbTab & dt.Rows(counter).Item("cpyTelSwitchBoard")
With (wapp.Selection)
.Font.Size = 9
.Font.Bold = True
.Font.Color = Word.WdColor.wdColorBlack
.TypeText(dt.Rows(counter).Item("conFirstName") & " " & dt.Rows(counter).Item("ConSurName"))
.Font.Bold = False
.TypeText(" " & strText)
.InsertBreak(Type:=Word.WdBreakType.wdLineBreak)
End With
Else
Count = counter - 1
Exit For
End If
Next
Next

wapp.Selection.InsertBreak(Type:=Word.WdBreakType.wdPageBreak)
wdoc.SaveAs(FileName)
Dim idoc As Word._Document
idoc = wdoc
idoc.Close()
Dim iapp As Word._Application
iapp = wapp
iapp.Quit()
wapp = Nothing
GC.Collect()
Catch ex As Exception
msgbox(ex.Message)
End Try
End Sub

if it does not work then your asp_net user do not have rights to use the word. go to control panel and in user accounts change the asp net user from limited to adminsitrator. Hopefully this will reolve your problem.

Regards
Rizwan Bashir
GeneralRe: word document in web application Pin
Manik Nath10-Jul-06 23:49
Manik Nath10-Jul-06 23:49 
GeneralRe: word document in web application Pin
Member 227165511-Jul-06 0:18
Member 227165511-Jul-06 0:18 
AnswerRe: word document in web application Pin
hemrk11-Jul-06 11:21
hemrk11-Jul-06 11:21 
QuestionConvert string to date?? Help??? Pin
Nathan Buckley10-Jul-06 20:32
Nathan Buckley10-Jul-06 20:32 
AnswerRe: Convert string to date?? Help??? Pin
Guffa10-Jul-06 23:48
Guffa10-Jul-06 23:48 
AnswerRe: Convert string to date?? Help??? Pin
paragyerawar11-Jul-06 0:07
paragyerawar11-Jul-06 0:07 
AnswerRe: Convert string to date?? Help??? Pin
<b<font color="#6EA3C4">MILAN@Cybage11-Jul-06 1:03
<b<font color="#6EA3C4">MILAN@Cybage11-Jul-06 1:03 
GeneralRe: Convert string to date?? Help??? Pin
Nathan Buckley11-Jul-06 13:43
Nathan Buckley11-Jul-06 13:43 
Questionauto upload/export of a downloaded CSV file to SQLSERVER on the server [modified] Pin
amitcoder8310-Jul-06 19:47
amitcoder8310-Jul-06 19:47 
QuestionForms Pin
K71810-Jul-06 16:23
K71810-Jul-06 16:23 
AnswerRe: Forms Pin
Dave Kreskowiak11-Jul-06 4:22
mveDave Kreskowiak11-Jul-06 4:22 
GeneralRe: Forms Pin
K71811-Jul-06 14:59
K71811-Jul-06 14:59 
GeneralRe: Forms Pin
Dave Kreskowiak11-Jul-06 16:58
mveDave Kreskowiak11-Jul-06 16:58 
GeneralRe: Forms Pin
K71811-Jul-06 17:20
K71811-Jul-06 17:20 
GeneralRe: Forms Pin
Dave Kreskowiak12-Jul-06 2:16
mveDave Kreskowiak12-Jul-06 2:16 
QuestionNull value error Pin
str5010-Jul-06 11:51
str5010-Jul-06 11:51 
AnswerRe: Null value error Pin
Christian Graus10-Jul-06 11:52
protectorChristian Graus10-Jul-06 11:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.