aman,
create a module in your excel workbook and add the following code
Public Sub printWordDocument()
On Error Resume Next
'#
'# declare private variables
'#
Dim objWordApplication As Object
Dim objDocument As Object
Dim strDocumentName As String
Const wdPrintAllDocument As Integer = 0
Const wdPrintDocumentWithMarkup As Integer = 7
Const wdPrintAllPages As Integer = 0
'#
'# get the document name specified by the user from cell A1 on the worksheet named
'# 'Sheet1' - modify to meet your requirements
'#
strDocumentName = ThisWorkbook.Worksheets("Sheet1").Range("A1").Value
'#
'# open the document specified by the user
'#
Set objWordApplication = CreateObject("Word.Application")
Set objDocument = objWordApplication.Documents.Open("J:\ABC\xxx\" & strDocumentName)
If objDocument Is Nothing Then
MsgBox "Sorry but document " & Chr$(34) & strDocumentName & Chr$(34) & " cannot be found"
objWordApplication.Quit
Set objDocument = Nothing
Set objWordApplication = Nothing
Exit Sub
End If
'#
'# print the document
'#
objDocument.PrintOut Range:=wdPrintAllDocument, Item:=wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
'#
'# housekeeping
'#
objDocument.Close
objWordApplication.Quit
Set objDocument = Nothing
Set objWordApplication = Nothing
End Sub
add a button to the worksheet where the user will specify the document name and link the button to the above routine. In the example code provided change the cell reference to the one where the user will be specifying the document name
Bookmarks