View Single Post
Old 08-01-2009, 09:20 PM
jandrade15 jandrade15 is offline Windows Vista Office 2007
Join Date: Aug 2009
Posts: 1
jandrade15 is on a distinguished road
Unhappy VBA Code for making "mailings" tab active

Hi Everyone,

I have a word doc that has the following code:
Private Sub Document_New()
    CommandBars("Mail merge").Visible = True

    Dim sPath As String
    CommandBars("Mail merge").Visible = True
    With ActiveDocument
        sPath = .Path & "\Tracking Data v.2.accdb"
        With .MailMerge
            .OpenDataSource _
                Name:=sPath, _
                ConfirmConversions:=False, _
                ReadOnly:=False, _
                LinkToSource:=True, _
                AddToRecentFiles:=False, _
                Revert:=False, _
                Format:=wdOpenFormatAuto, _
                Connection:= _
                    "Provider=Microsoft.ACE.OLEDB.12.0; " & _
                    "User ID=Admin;" & _
                    "Password='';" & _
                    "Data Source=" & sPath & ";" & _
                    "Mode=Read;", _
                SQLStatement:="SELECT * FROM `Farming_Table`", _
                SQLStatement1:="", _
            .ViewMailMergeFieldCodes = wdToggle
        End With
    End With
End Sub
this was for a 2003 doc and now I cant get the "mailings" tab to be pop up after the code is done? It opens up with the home tab and I want the mailings tab seems that the commandbars code is incorrect since it doesn't reference the tab fields? Does anyone know how to make this happen? Thanks a million for any help!! This has been quite frustrating!
Reply With Quote