Click here to Skip to main content
15,896,507 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: vb.net desk app using app.config file Pin
Dave Kreskowiak1-Jun-18 13:24
mveDave Kreskowiak1-Jun-18 13:24 
GeneralRe: vb.net desk app using app.config file Pin
dcof4-Jun-18 9:56
dcof4-Jun-18 9:56 
GeneralRe: vb.net desk app using app.config file Pin
Dave Kreskowiak4-Jun-18 11:13
mveDave Kreskowiak4-Jun-18 11:13 
GeneralRe: vb.net desk app using app.config file Pin
dcof5-Jun-18 4:21
dcof5-Jun-18 4:21 
GeneralRe: vb.net desk app using app.config file Pin
Dave Kreskowiak5-Jun-18 5:45
mveDave Kreskowiak5-Jun-18 5:45 
GeneralRe: vb.net desk app using app.config file Pin
dcof5-Jun-18 7:48
dcof5-Jun-18 7:48 
GeneralRe: vb.net desk app using app.config file Pin
Dave Kreskowiak5-Jun-18 8:11
mveDave Kreskowiak5-Jun-18 8:11 
QuestionInserting to new table in between two table in ms word from vb.net Pin
Osioghole Clifford28-May-18 13:50
Osioghole Clifford28-May-18 13:50 
Hello .... Please someone help me out. I want to insert new table in ms word from vb.net application, I use bookmark to define the range but it still give error "the range cannot be delete", below is my code.

Public Sub invoicePrinting1(ByVal strBasePath As String, ByVal userid As String)
        Dim oWord = New Word.Application With {.Visible = False}
        Dim oDoc As Word.Document = oWord.Documents.Open(strBasePath)
        Dim pos, len As Integer
        Dim reg As Regex
        Dim bookmarkName As String
        Dim rng As Object
        Dim search As String = "@@Item_List1@@"
        Dim dgv As DataGridView = printbox.DGVacct


        Dim headers = (From ch In dgv.Columns
                       Let header = DirectCast(DirectCast(ch, DataGridViewColumn).HeaderCell, DataGridViewColumnHeaderCell)
                       Select header.Value).ToArray()
        Dim headerText() As String = Array.ConvertAll(headers, Function(v) v.ToString)

        Dim items() = (From r In dgv.Rows
                       Let row = DirectCast(r, DataGridViewRow)
                       Where Not row.IsNewRow
                       Select (From cell In row.Cells
                               Let c = DirectCast(cell, DataGridViewCell)
                               Select c.Value).ToArray()).ToArray()

        Dim table As String = String.Join(vbTab, headerText) & Environment.NewLine
        For Each a In items
            Dim t() As String = Array.ConvertAll(a, Function(v) v.ToString)
            table &= String.Join(vbTab, t) & Environment.NewLine
        Next

        table = table.TrimEnd(CChar(Environment.NewLine))
        Clipboard.SetText(table)

        ' keyword that you want to search
        reg = New Regex(search)
        ' find the text in word file
        Dim m As Match = reg.Match(oDoc.Range.Text, 0)
        pos = m.Index

        ' start is the starting position of the token in the content...
        len = search.Length
        ' select the text
        rng = oDoc.Range(pos, len + pos)

        bookmarkName = "MyBookmarkName"
        oDoc.Bookmarks.Add(bookmarkName, rng)
        Dim tdRange As Word.Range = oDoc.Range(0, pos)
        With tdRange
            .Collapse(Direction:=Word.WdCollapseDirection.wdCollapseEnd)
            .InsertParagraphAfter()
            .Collapse(Direction:=Word.WdCollapseDirection.wdCollapseEnd)

        End With
        Dim oTable As Word.Tablespoons = oDoc.Tables.Add(oDoc.Bookmarks.Item(bookmarkName).Range, items.Count + 1, headers.Count)

        oTable.Range.Paste()


        oTable.Range.Font.Size = 9
        'make the first row bold, fs 14 + change textcolor
        oTable.Rows.Item(1).Range.Font.Bold = &H98967E
        oTable.Rows.Item(1).Range.Font.Size = 10
        oTable.Rows.Item(1).Height = 20
        oTable.Rows.Item(1).Range.Font.Color = Word.WdColor.wdColorWhite
        oTable.Range.AutoFormat()

        'change backcolor of first row
        oTable.Rows.Item(1).Range.Shading.Texture = Word.WdTextureIndex.wdTextureNone
        oTable.Rows.Item(1).Range.Shading.ForegroundPatternColor = Word.WdColor.wdColorAutomatic
        oTable.Rows.Item(1).Range.Shading.BackgroundPatternColor = Word.WdColor.wdColorGray25

        'set table borders
        With oTable
            .Columns(1).SetWidth(oDoc.Application.CentimetersToPoints(wd(4.3F)), Word.WdRulerStyle.wdAdjustProportional)
            .Columns(2).SetWidth(oDoc.Application.CentimetersToPoints(wd(10.5F)), Word.WdRulerStyle.wdAdjustProportional)
            .Columns(3).SetWidth(oDoc.Application.CentimetersToPoints(wd(4.8F)), Word.WdRulerStyle.wdAdjustProportional)
            .Columns(4).SetWidth(oDoc.Application.CentimetersToPoints(wd(5.0F)), Word.WdRulerStyle.wdAdjustProportional)
        End With
        'set table borders
        With oTable.Range.Tables(1)


            With .Borders(Word.WdBorderType.wdBorderLeft)
                .LineStyle = Word.WdLineStyle.wdLineStyleSingle
                .LineWidth = Word.WdLineWidth.wdLineWidth025pt
                .Color = Word.WdColor.wdColorAutomatic
            End With
            With .Borders(Word.WdBorderType.wdBorderRight)
                .LineStyle = Word.WdLineStyle.wdLineStyleSingle
                .LineWidth = Word.WdLineWidth.wdLineWidth025pt
                .Color = Word.WdColor.wdColorAutomatic
            End With
            With .Borders(Word.WdBorderType.wdBorderTop)
                .LineStyle = Word.WdLineStyle.wdLineStyleSingle
                .LineWidth = Word.WdLineWidth.wdLineWidth025pt
                .Color = Word.WdColor.wdColorAutomatic
            End With
            With .Borders(Word.WdBorderType.wdBorderBottom)
                .LineStyle = Word.WdLineStyle.wdLineStyleSingle
                .LineWidth = Word.WdLineWidth.wdLineWidth025pt
                .Color = Word.WdColor.wdColorAutomatic
            End With
            With .Borders(Word.WdBorderType.wdBorderHorizontal)
                .LineStyle = Word.WdLineStyle.wdLineStyleSingle
                .LineWidth = Word.WdLineWidth.wdLineWidth025pt
                .Color = Word.WdColor.wdColorAutomatic
            End With
            With .Borders(Word.WdBorderType.wdBorderVertical)
                .LineStyle = Word.WdLineStyle.wdLineStyleSingle
                .LineWidth = Word.WdLineWidth.wdLineWidth025pt
                .Color = Word.WdColor.wdColorAutomatic
            End With
            .Borders(Word.WdBorderType.wdBorderDiagonalDown).LineStyle = Word.WdLineStyle.wdLineStyleNone
            .Borders(Word.WdBorderType.wdBorderDiagonalUp).LineStyle = Word.WdLineStyle.wdLineStyleNone
            .Borders.Shadow = False
            .Rows.Height = 7
        End With

        oDoc.Save()
        oWord.Quit()
        oDoc = Nothing
        oWord = Nothing
    End Sub

QuestionLINQ: How To Make Order By Conditional? Pin
Alan Burkhart26-May-18 16:05
Alan Burkhart26-May-18 16:05 
AnswerRe: LINQ: How To Make Order By Conditional? Pin
Richard MacCutchan27-May-18 1:05
mveRichard MacCutchan27-May-18 1:05 
GeneralRe: LINQ: How To Make Order By Conditional? Pin
Alan Burkhart29-May-18 14:42
Alan Burkhart29-May-18 14:42 
AnswerRe: LINQ: How To Make Order By Conditional? Pin
Richard Deeming30-May-18 9:58
mveRichard Deeming30-May-18 9:58 
GeneralRe: LINQ: How To Make Order By Conditional? Pin
Mycroft Holmes30-May-18 14:27
professionalMycroft Holmes30-May-18 14:27 
GeneralRe: LINQ: How To Make Order By Conditional? Pin
Richard Deeming31-May-18 1:15
mveRichard Deeming31-May-18 1:15 
GeneralRe: LINQ: How To Make Order By Conditional? Pin
Alan Burkhart31-May-18 7:18
Alan Burkhart31-May-18 7:18 
GeneralRe: LINQ: How To Make Order By Conditional? Pin
Alan Burkhart31-May-18 7:33
Alan Burkhart31-May-18 7:33 
QuestionWebBrowser Javascript Error handing via HtmlWindow works in IE8 mode but not in IE10 or Edge. Pin
Jeffrey Cobb26-May-18 15:55
Jeffrey Cobb26-May-18 15:55 
QuestionOutlook Mail Drag Drop into Textbox of a Win Form Pin
HPS-Software24-May-18 18:41
HPS-Software24-May-18 18:41 
AnswerRe: Outlook Mail Drag Drop into Textbox of a Win Form Pin
Richard Deeming25-May-18 2:35
mveRichard Deeming25-May-18 2:35 
GeneralRe: Outlook Mail Drag Drop into Textbox of a Win Form Pin
HPS-Software26-May-18 20:51
HPS-Software26-May-18 20:51 
GeneralRe: Outlook Mail Drag Drop into Textbox of a Win Form Pin
Eddy Vluggen26-May-18 23:05
professionalEddy Vluggen26-May-18 23:05 
GeneralRe: Outlook Mail Drag Drop into Textbox of a Win Form Pin
HPS-Software27-May-18 18:14
HPS-Software27-May-18 18:14 
QuestionSave in datagriedview in application Pin
Member 1361197220-May-18 8:13
Member 1361197220-May-18 8:13 
AnswerRe: Save in datagriedview in application Pin
Dave Kreskowiak20-May-18 11:40
mveDave Kreskowiak20-May-18 11:40 
GeneralRe: Save in datagriedview in application Pin
Member 1361197221-May-18 1:26
Member 1361197221-May-18 1:26 

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.