Thread: [Solved] Word GoTo From Excel
View Single Post
 
Old 12-07-2012, 03:10 PM
mata30s mata30s is offline Windows 7 64bit Office 2007
Novice
 
Join Date: Nov 2012
Posts: 13
mata30s is on a distinguished road
Default

I have replaced some text with three dots (...) since they contain info I do not want to release

Code:
        Dim wrdApp As Word.Application
        Dim wrdDoc As Word.Document
        Dim i As Integer
        Set wrdApp = CreateObject("Word.Application")
        wrdApp.Visible = True
        Set wrdDoc = wrdApp.Documents.Open(directory)
 
        With wrdDoc
 
            If .Bookmarks.Exists(table_name) Then
                With .Bookmarks(table_name).Range
                    If .Tables.Count > 0 Then
                        ... 
                    Else
                        ...                      
                    End If
 
                End With
 
            Else
                ... 
                With .Tables(1)
                    If .Style <> "Table Grid" Then
                        .Style = "Table Grid"
                    End If
                    .ApplyStyleHeadingRows = True
                    .ApplyStyleLastRow = False
                    .ApplyStyleFirstColumn = True
                    .ApplyStyleLastColumn = False
                    .ApplyStyleRowBands = True
                    .ApplyStyleColumnBands = False
                End With
 
                 .Bookmarks.Add Name:=table_name 
                 
                With .Tables(1)
 
                     With .Cell(1, 1)
                         .Range.Text = ...
                        .Select
                        .Application.Run MacroName:=...
                     End With
 
                     .Cell(1, 2).Range.Text = ...
                     .Cell(1, 3).Range.Text = ... 
                     With .Cell(2, 1)
                        .Select
                        .Range.Bookmarks.Add Name:=...
                        .Range.Text = ...
                     End With
 
                    With .Cell(2, 2)
                        .Shading.Texture = wdTextureNone
                        .Shading.ForegroundPatternColor = wdColorAutomatic
                        .Shading.BackgroundPatternColor = -721354753
                    End With
                    With .Cell(2, 3)
                        .Shading.Texture = wdTextureNone
                        .Shading.ForegroundPatternColor = wdColorAutomatic
                        .Shading.BackgroundPatternColor = -721354753
                    End With
 
                End With
 
            End If
 
        End With
Reply With Quote