none
VBA Excel error 6028 repeated table RRS feed

  • Question

  • Hello support of Microsoft,

    I have made a VBA-macro in Excel (office2010) to automated a report. I have a Excel sheet where I have a lot of data. With mail merge I made a report of it. The problem is I get an error 6028 and I don't know where it comes from. I have made a loop where I call several times a table with data. When I call it the second time the error appears.  

    When the error appears, VBA-excel marks the next row yellow:  Set tabel2 = wordRange.Tables.Add(wordRange, 4, 7, wdWord9TableBehavior, wdAutoFitFixed)

    with wordRange: Set wordRange = wordApp.ActiveDocument.Range(wordApp.ActiveDocument.Range.Characters.Count - 1)

    I goes wrong after the second loop:

                    Do While Cells(r, 2) = Cells(r + s, 2)
                           ChanRichting
                           NextRecord
                           s = s + 1
                    Loop

    Please, could somebody help me to solve this problem?

    Thank you!

    byBird

    _________VBA code:______________________

    The total code is about 500 rows, but a part of it is like this:

    Option Explicit

    ''''''''''''''''''''''''''Variabele en Constante''''''''''''''''''''''''''''''''''''''''''''
    Public wordRange As Object
    Public tabel1 As Table
    Public tabel2 As Table
    Public oCell As Object

    Public Locatie As String
    Public wordApp As Word.Application
    Public wordDoc As Word.Document
    Public CHpos As String
    Public CHposnext As String
    Public r As Long
    Public s As Long
    Public t As Long
    Public v As Long
    Public IstartedXL As Boolean

    'Instellingen m.b.t. tabelkolombreedte
    Public Const Tabelshift As Double = -5.7
    Public Const kolom1 As Double = 30
    Public Const kolom2 As Double = 100
    Public Const kolom3 As Double = 50
    Public Const kolom4 As Double = 130
    Public Const kolom5 As Double = 115
    Public Const kolom6 As Double = 50
    Public Const kolom7 As Double = 50
    'Mailmerge routine
    Public Const Tabblad As String = "SELECT * FROM `Kanaallijst$`"
    Public Const EersteRecord As Long = 1
    Public LaatsteRecord As Long

    Public Sub DetailMeas_script()
    'oproepen van andere Sub gewoonweg de sub naam opnoemen zonder haakjes

    ''''''''''''''''''''''''Variabele die alleen in deze sub worden gebruikt''''''''''''''''''''''''''
     Dim intchoice As Integer

    ''''''''''''''''''''''''Start Hoofdprogramma''''''''''''''''''''''''''''''

    Locatie = "C:\Users\vincent vogel\Desktop\Template Generate files.dotx"

    Set wordApp = CreateObject("Word.Application")
        Set wordDoc = wordApp.Documents.Add(Template:=Locatie)
        wordApp.Visible = True
       
    On Error Resume Next
        'excelprogramma opstarten
        Set wordApp = GetObject(, "Word.Application")
    On Error GoTo 0
        If wordApp Is Nothing Then
            Set wordApp = CreateObject("Word.Application")
            IstartedXL = True
            End If
     
        'Exceltabblad openen en declareren aan de variabele CHpos en CHposnext
        CHpos = CHposnext = Sheets("Kanaallijst").Range("B2").Value
        'Tellen van aantal rijen min 1 ivm header
        LaatsteRecord = Sheets("Kanaallijst").Cells(Rows.Count, "B").End(xlUp).row - 1
        'Velden "Detail Measurement Locations" document genereren
        Looping
        'Mail Merge activeren
        'Sluit de geopende Excelsheet
    '    wordDoc.Close SaveChanges:=False ' close the workbook without saving
    '    If IstartedXL Then xlApp.Quit ' close the Excel application
        Set wordDoc = Nothing
        Set wordApp = Nothing
    End Sub
    Sub Looping()
    ''''''''''''''''''''''''''''''Variabelen''''''''''''''''''''''''''''''''''''''''''''''''''''

      
        'twee variabele:    r = 2 omdat het bij de tweede rij moet beginnen (eerste rij is de header)
        '                   s = 1 deze loopt op naar gelang er een dubbele naam achter de vorige regel voorkomt
        r = 2
        s = 1
        t = v = 1
        'als de betreffende cel niet leeg is dan volgt hij de loop. De loop kijkt naar de tweede kolom en gaat met r alle rijen af
        Do While Cells(r, 2) <> ""
            'CHpos = channel positie. Hieronder wordt de cellocatie van kolom 2 = B en de variabele r bekeken
            CHpos = Sheets("Kanaallijst").Range("B" & r).Value
            'CHpos = channel positie. Hieronder wordt de cellocatie van kolom 2 = B en de variabele s bekeken
            CHposnext = Sheets("Kanaallijst").Range("B" & s).Value
                           'hieronder worden de Sub [naam]() gedeclareerd
                           v = r - 1
                           Do While Cells(r, 2) = Cells(r + t, 2)
                           t = t + 1
                           Loop
    '                       Debug.Print (v & " " & v + (t - 1))
                           ChanPositieTitel
                           t = 1
                           ChanRichting
                           NextRecord
                    'Hieronder worden de cel r vergeleken met de voorgaande cel, wanneer deze aan elkaar gelijk zijn blijft deze in de loop zitten
                    'Hierdoor zal 1, 2 of 3 of meer sensorrichtingen op dezelfde pagina komen te staan
                    Do While Cells(r, 2) = Cells(r + s, 2)
                           ChanRichting
                           NextRecord
                           s = s + 1
                    Loop
                    r = r + s
                    ' s wordt gereset zodat in een volgende loop het aantal sensorrichting weer bepaald kunnen worden
                    s = 1

                    'Pagina-einde
                    wordApp.Selection.InsertBreak Type:=wdPageBreak
        Loop
        wordApp.Selection.TypeBackspace
            wordApp.Selection.TypeBackspace
                wordApp.Selection.TypeBackspace
    End Sub
    Sub ChanPositieTitel()
    ' Merge velden opmaken
        With wordApp.Selection
            .Style = wordApp.ActiveDocument.Styles("Kop 3")
            .Fields.Add Range:=wordApp.Selection.Range, Type:=wdFieldEmpty, _
                PreserveFormatting:=False
            .TypeText Text:="IF"
            .Fields.Add Range:=wordApp.Selection.Range, Type:=wdFieldEmpty, _
            PreserveFormatting:=False
            .TypeText Text:="MERGESEQ"
            .MoveRight Unit:=wdCharacter, Count:=2
            .TypeText Text:="=""1"" ""A1.6"
    '       .Fields.Add Range:=wordApp.Selection.Range, Type:=wdFieldEmpty, _
    '           PreserveFormatting:=False
    '       .TypeText Text:="MERGESEQ"
    '       .MoveRight Unit:=wdCharacter, Count:=2
            .TypeText Text:=" Channel " & v & "-" & v + (t - 1) & "-"
            .Fields.Add Range:=wordApp.Selection.Range, Type:=wdFieldEmpty, _
                PreserveFormatting:=False
            .TypeText Text:="MERGEFIELD Channelgroup_position"
            .EndKey
            .MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
            .TypeParagraph
        End With
    End Sub

    Sub ChanRichting()

    'Alinea instellingen
         With wordApp.Selection
            .Style = wordApp.ActiveDocument.Styles("Standaard")
            With .ParagraphFormat
                .LeftIndent = wordApp.CentimetersToPoints(0)
                .RightIndent = wordApp.CentimetersToPoints(0)
                .SpaceBefore = 1
                .SpaceBeforeAuto = False
                .SpaceAfter = 1
                .SpaceAfterAuto = False
                .LineSpacingRule = wdLineSpaceSingle
                .Alignment = wdAlignParagraphLeft
                .WidowControl = True
                .KeepWithNext = False
                .KeepTogether = False
                .PageBreakBefore = False
                .NoLineNumber = False
                .Hyphenation = True
                .FirstLineIndent = wordApp.CentimetersToPoints(0)
                .OutlineLevel = wdOutlineLevelBodyText
                .CharacterUnitLeftIndent = 0
                .CharacterUnitRightIndent = 0
                .CharacterUnitFirstLineIndent = 0
                .LineUnitBefore = 0
                .LineUnitAfter = 0
                .MirrorIndents = False
                .TextboxTightWrap = wdTightNone
            End With
            With .Font
                .Size = 10
                .Name = "Arial"
            End With
        End With

        'Tabel aanmaken
     Set wordRange = wordApp.ActiveDocument.Range(wordApp.ActiveDocument.Range.Characters.Count - 1)
     Set tabel2 = wordRange.Tables.Add(wordRange, 4, 7, wdWord9TableBehavior, wdAutoFitFixed)
      With tabel2
        'Kolombreedte instellen
       .Rows.SetLeftIndent LeftIndent:=Tabelshift, RulerStyle:=wdAdjustNone
        .Columns(1).SetWidth ColumnWidth:=kolom1, RulerStyle:=wdAdjustNone
        .Columns(2).SetWidth ColumnWidth:=kolom2, RulerStyle:=wdAdjustNone
        .Columns(3).SetWidth ColumnWidth:=kolom3, RulerStyle:=wdAdjustNone
        .Columns(4).SetWidth ColumnWidth:=kolom4, RulerStyle:=wdAdjustNone
        .Columns(5).SetWidth ColumnWidth:=kolom5, RulerStyle:=wdAdjustNone
        .Columns(6).SetWidth ColumnWidth:=kolom6, RulerStyle:=wdAdjustNone
        .Columns(7).SetWidth ColumnWidth:=kolom7, RulerStyle:=wdAdjustNone
            'opmaak
        .Columns(3).Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
        .Columns(4).Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
        .Columns(5).Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
        .Columns(6).Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
        .Columns(7).Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
       
        'Cellen samenvoegen
        .Columns(1).Select
        .Columns(1).Cells.Merge
        .Columns(2).Select
        .Columns(2).Cells.Merge
        .Cell(1, 4).Merge MergeTo:=wordApp.Selection.Tables(1).Cell(1, 7)
        .Cell(2, 6).Merge MergeTo:=wordApp.Selection.Tables(1).Cell(2, 7)
        .Cell(4, 6).Merge MergeTo:=wordApp.Selection.Tables(1).Cell(4, 7)

        'Tabel invullen
         Set oCell = tabel2.Cell(1, 1).Range 'cel
         oCell.End = oCell.End - 1 'omit the cell end marker from the range
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD Channel_no", PreserveFormatting:=False 'Add the field

         Set oCell = tabel2.Cell(1, 2).Range
         oCell.End = oCell.End - 1
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD Shortname", PreserveFormatting:=False

         Set oCell = tabel2.Cell(1, 3).Range
         oCell.End = oCell.End - 1
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD Unit", PreserveFormatting:=False

         Set oCell = tabel2.Cell(1, 4).Range
         oCell.End = oCell.End - 1
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD Long_Name", PreserveFormatting:=False

         Set oCell = tabel2.Cell(2, 3).Range
         oCell.End = oCell.End - 1
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD Sign_Convention", PreserveFormatting:=False

         Set oCell = tabel2.Cell(2, 4).Range
         oCell.End = oCell.End - 1
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD Sensor_No", PreserveFormatting:=False

         Set oCell = tabel2.Cell(3, 4).Range
         oCell.End = oCell.End - 1
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD Range \# 0,0", PreserveFormatting:=False

         Set oCell = tabel2.Cell(4, 4).Range
         oCell.End = oCell.End - 1
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD DeviceNo", PreserveFormatting:=False

         Set oCell = tabel2.Cell(2, 5).Range
         oCell.End = oCell.End - 1
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD BrandType", PreserveFormatting:=False

         Set oCell = tabel2.Cell(3, 5).Range
         oCell.End = oCell.End - 1
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD Sensitivity_Value \# 0,000", PreserveFormatting:=False

         Set oCell = tabel2.Cell(4, 5).Range
         oCell.End = oCell.End - 1
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD Connection_board", PreserveFormatting:=False

         Set oCell = tabel2.Cell(2, 6).Range
         oCell.End = oCell.End - 1
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD SerialNo \# 0", PreserveFormatting:=False

         Set oCell = tabel2.Cell(3, 6).Range
         oCell.End = oCell.End - 1
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD Calibration_Value \# 0,000", PreserveFormatting:=False

         Set oCell = tabel2.Cell(3, 7).Range
         oCell.End = oCell.End - 1
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD Verification_Value \# 0,000", PreserveFormatting:=False

         Set oCell = tabel2.Cell(4, 6).Range
         oCell.End = oCell.End - 1
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD Gage_Factor \# 0,00", PreserveFormatting:=False
       
      End With
        wordApp.Selection.EndKey Unit:=wdStory
    End Sub
    Sub RegelVerkleinen()

    'Regel verkleinen
          With wordApp.Selection
            .Style = wordApp.ActiveDocument.Styles("Standaard")
            With .ParagraphFormat
                .LeftIndent = wordApp.CentimetersToPoints(0)
                .RightIndent = wordApp.CentimetersToPoints(0)
                .SpaceBefore = 0
                .SpaceBeforeAuto = False
                .SpaceAfter = 0
                .SpaceAfterAuto = False
                .LineSpacingRule = wdLineSpaceMultiple
                .LineSpacing = wordApp.LinesToPoints(1)
                .Alignment = wdAlignParagraphLeft
                .WidowControl = True
                .KeepWithNext = False
                .KeepTogether = False
                .PageBreakBefore = False
                .NoLineNumber = False
                .Hyphenation = True
                .FirstLineIndent = wordApp.CentimetersToPoints(0)
                .OutlineLevel = wdOutlineLevelBodyText
                .CharacterUnitLeftIndent = 0
                .CharacterUnitRightIndent = 0
                .CharacterUnitFirstLineIndent = 0
                .LineUnitBefore = 0
                .LineUnitAfter = 0
                .MirrorIndents = False
                .TextboxTightWrap = wdTightNone
            End With
            With .Font
                .Size = 1
                .Name = "Arial"
            End With
        End With
        wordApp.Selection.TypeParagraph
    End Sub
    Sub NextRecord()
            'alinearegel definieren
       With wordApp.Selection
            .Style = wordApp.ActiveDocument.Styles("Standaard")
            With .ParagraphFormat
                .LeftIndent = wordApp.CentimetersToPoints(0)
                .RightIndent = wordApp.CentimetersToPoints(0)
                .SpaceBefore = 0
                .SpaceBeforeAuto = False
                .SpaceAfter = 0
                .SpaceAfterAuto = False
                .LineSpacingRule = wdLineSpaceMultiple
                .LineSpacing = wordApp.LinesToPoints(1)
                .Alignment = wdAlignParagraphLeft
                .WidowControl = True
                .KeepWithNext = False
                .KeepTogether = False
                .PageBreakBefore = False
                .NoLineNumber = False
                .Hyphenation = True
                .FirstLineIndent = wordApp.CentimetersToPoints(0)
                .OutlineLevel = wdOutlineLevelBodyText
                .CharacterUnitLeftIndent = 0
                .CharacterUnitRightIndent = 0
                .CharacterUnitFirstLineIndent = 0
                .LineUnitBefore = 0
                .LineUnitAfter = 0
                .MirrorIndents = False
                .TextboxTightWrap = wdTightNone
            End With
            With .Font
                .Size = 1 'Deze enter moet klein!!!
            End With
        End With
        'veld aanmaken met volgende record
        wordApp.Selection.Fields.Add Range:=wordApp.Selection.Range, Type:=wdFieldEmpty, _
            PreserveFormatting:=False
        wordApp.Selection.TypeText Text:="Next"
        wordApp.Selection.EndKey
        wordApp.Selection.TypeParagraph
        wordApp.Selection.Style = wordApp.ActiveDocument.Styles("Standaard")
    End Sub


    • Edited by byBird Tuesday, November 11, 2014 6:52 AM
    Sunday, November 9, 2014 10:37 PM

Answers

  • Hi byBird,

    Based on the code, you are insert fileds and tables into document. And as far as I test, the error diplayed when we insert third tables. It seems that you want to to insert the tables at the end of docuemnt when you insert tables.

    If I understood correctly, we can use wordApp.Selection.EndKey Unit:=wdStory to move the selection to the end of document. And here is a samlpe for your reference:

    Sub tabelletjes()
     Dim tabel1 As Table
     Dim wordRange As Object
     Dim oCell As Object
         Set wordRange = wordApp.ActiveDocument.Range(wordApp.ActiveDocument.Range.Characters.Count - 1)
         wordApp.Selection.EndKey Unit:=wdStory
     '    Set wordRange = wordDoc.Range(wordDoc.Range.Characters.Count - 1)
         'Set tabel1 = wordRange.Tables.Add(wordRange, 4, 7, wdWord9TableBehavior, wdAutoFitFixed)
         Set tabel1 = wordApp.Selection.Range.Tables.Add(wordApp.Selection.Range, 4, 7, wdWord9TableBehavior, wdAutoFitFixed)
         
         Set oCell = tabel1.Cell(1, 1).Range 'cel
          oCell.End = oCell.End - 1 'omit the cell end marker from the range
          oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD Channel_no", PreserveFormatting:=False 'Add the field
     End Sub
    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, November 12, 2014 7:13 AM
    Moderator

All replies

  • Hi byBird,

    Thanks for posting in MSDN forum.

    >>When the error appears, VBA-excel marks the next row yellow:  Set tabel2 = wordRange.Tables.Add(wordRange, 4, 7, wdWord9TableBehavior, wdAutoFitFixed)<<

    If I understood correctly, you got an error when you execute the code motioned above at the seconded time. I try to reproduce the issue however failed. And based on the error message 6028(Application-defined or object-defined error):
    I suggest that you check whether the range is suitable to add the table again. If the issue still exists, would you mind sharing with a code sample to help us to reproduce this issue? You can remove the sensitive the information and upload it via OneDrive.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, November 11, 2014 6:07 AM
    Moderator
  • Hello Fei,

    Thank you for your help!

    I have made it easier to share, with a shorter code for VBA Excel. Your are right, the problem lies in the range indeed, but I don't know where to change in. If I change the code, to make ocell rows in comment then the code do not fail. If I change the table As Object It wouln't work. Either with oCell as Range. So, what is the best format to change in?

    Thanks,

    ByBird

    ______________Code:________________________

    Public r As Long
    Public s As Long
    Public t As Long
    Public v As Long

    Public wordApp As Word.Application
    Public wordDoc As Word.Document

    Sub help()

    Set wordApp = CreateObject("Word.Application")
        Set wordDoc = wordApp.Documents.Add
        wordApp.Visible = True
       
        r = 2
        s = 1
       
        ChanPositieTitel
        nogeentabel
        wordApp.Selection.EndKey Unit:=wdStory
        ChanPositieTitel
            Do While Cells(r, 2) = Cells(r + s, 2)
                tabelletjes
                wordApp.Selection.EndKey Unit:=wdStory
                ChanPositieTitel
                s = s + 1
            Loop
        nogeentabel
       
        Set wordDoc = Nothing
        Set wordApp = Nothing

    End Sub
    Sub tabelletjes()
    Dim tabel1 As Table
    Dim wordRange As Object
    Dim oCell As Object
        Set wordRange = wordApp.ActiveDocument.Range(wordApp.ActiveDocument.Range.Characters.Count - 1)
    '    Set wordRange = wordDoc.Range(wordDoc.Range.Characters.Count - 1)
        Set tabel1 = wordRange.Tables.Add(wordRange, 4, 7, wdWord9TableBehavior, wdAutoFitFixed)
       
        Set oCell = tabel1.Cell(1, 1).Range 'cel
         oCell.End = oCell.End - 1 'omit the cell end marker from the range
         oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD Channel_no", PreserveFormatting:=False 'Add the field
    End Sub
    Sub nogeentabel()
    Dim tabel1 As Table
    Dim wordRange As Object
        Set wordRange = wordApp.ActiveDocument.Range(wordApp.ActiveDocument.Range.Characters.Count - 1)
    '    Set wordRange = wordDoc.Range(wordDoc.Range.Characters.Count - 1)
        Set tabel1 = wordRange.Tables.Add(wordRange, 4, 7, wdWord9TableBehavior, wdAutoFitFixed)
    End Sub

    Sub ChanPositieTitel()
    ' Merge velden opmaken
        With wordApp.Selection
            .Style = wordApp.ActiveDocument.Styles("Kop 3")
            .Fields.Add Range:=wordApp.Selection.Range, Type:=wdFieldEmpty, _
                PreserveFormatting:=False
            .TypeText Text:="IF"
            .Fields.Add Range:=wordApp.Selection.Range, Type:=wdFieldEmpty, _
            PreserveFormatting:=False
            .TypeText Text:="MERGESEQ"
            .MoveRight Unit:=wdCharacter, Count:=2
            .TypeText Text:="=""1"" ""A1.6"
    '       .Fields.Add Range:=wordApp.Selection.Range, Type:=wdFieldEmpty, _
    '           PreserveFormatting:=False
    '       .TypeText Text:="MERGESEQ"
    '       .MoveRight Unit:=wdCharacter, Count:=2
            .TypeText Text:=" Channel " & v & "-" & v + (t - 1) & "-"
            .Fields.Add Range:=wordApp.Selection.Range, Type:=wdFieldEmpty, _
                PreserveFormatting:=False
            .TypeText Text:="MERGEFIELD Channelgroup_position"
            .EndKey
            .MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
            .TypeParagraph
        End With
    End Sub

    Tuesday, November 11, 2014 7:15 AM
  • Hi byBird,

    Based on the code, you are insert fileds and tables into document. And as far as I test, the error diplayed when we insert third tables. It seems that you want to to insert the tables at the end of docuemnt when you insert tables.

    If I understood correctly, we can use wordApp.Selection.EndKey Unit:=wdStory to move the selection to the end of document. And here is a samlpe for your reference:

    Sub tabelletjes()
     Dim tabel1 As Table
     Dim wordRange As Object
     Dim oCell As Object
         Set wordRange = wordApp.ActiveDocument.Range(wordApp.ActiveDocument.Range.Characters.Count - 1)
         wordApp.Selection.EndKey Unit:=wdStory
     '    Set wordRange = wordDoc.Range(wordDoc.Range.Characters.Count - 1)
         'Set tabel1 = wordRange.Tables.Add(wordRange, 4, 7, wdWord9TableBehavior, wdAutoFitFixed)
         Set tabel1 = wordApp.Selection.Range.Tables.Add(wordApp.Selection.Range, 4, 7, wdWord9TableBehavior, wdAutoFitFixed)
         
         Set oCell = tabel1.Cell(1, 1).Range 'cel
          oCell.End = oCell.End - 1 'omit the cell end marker from the range
          oCell.Fields.Add oCell, Type:=wdFieldEmpty, Text:="MERGEFIELD Channel_no", PreserveFormatting:=False 'Add the field
     End Sub
    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, November 12, 2014 7:13 AM
    Moderator
  • Hello Fei!

    Thank you so much! This problem is solved now!!!

    I am so happy :D

    Best regards,

    ByBird

    Wednesday, November 12, 2014 12:58 PM