Created
April 29, 2015 18:16
-
-
Save SalvaJ/5f607ff1394cd96f3608 to your computer and use it in GitHub Desktop.
This macro VBA example creates a Word doc and fill Form Fiels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub OpenPINDoc() | |
' | |
' Open PIN Doc Macro for New TN Client | |
' This example creates a Word doc and fill Form Fiels | |
Dim xlApp As Object | |
Dim wdApp As Object | |
Dim xlString As String | |
Dim catString As String | |
Dim storString As String | |
Dim dotString As String | |
Dim pinString As String | |
Sheets("Doc_Index").Select | |
storString = Sheets("Doc_Index").Range("B2") | |
dotString = Sheets("Doc_Index").Range("C2") | |
pinString = storString & dotString | |
Sheets("Pin_Index").Select | |
xlvalString = Sheets("Doc_Index").Range("F1") | |
'Open Word Instance | |
Set wdApp = CreateObject("Word.Application") | |
wdApp.Visible = True | |
'Open Template as Document | |
wdApp.Documents.Add Template:=(pinString) | |
wdApp.Activate | |
'Prefill Data | |
With wdApp.ActiveDocument | |
.FormFields("docCategory").Result = xlvalString | |
End With | |
'Clear | |
Set xlApp = Nothing | |
Set wdApp = Nothing | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment