Print a word doc from a drop down list

Craig1

Active Member
Joined
Jun 11, 2009
Messages
322
Hi All,
Not sure if this can be done, I have searched the forum to find a way but with no success.
I have an "issue control" excel sheet, column B has a drop down list with over 200 documents, the drop down list has the title of each document, but all these documents are in word, so the list corresponds to all the word documents. What I want to be able to do is add a print button in each row to print off the relevant document in the opposite cell.
So if cell B4 is "Check and repair belts on FA501 and FA502" I want the print button to locate the word document in B4, open it if needed and print it off.

Is this possible?

Craig.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
HTML:
Set wrdApp = CreateObject("Word.Application") 
    Set wrdDoc = wrdApp.Documents.Open("document.dot") 
    
    wrdDoc.PrintOut 
    wrdDoc.Close 
    wrdApp.Quit
 
Last edited:
Upvote 0
Thanks for the reply Tropix100.
I got an error saying it couldn't find the file, the problem I have is the drop down box could contain one of over 200 documents so I was thinking something along the lines of below or something similar

Set wrdDoc = wrdApp.Documents.Open("B4.dot")

Craig
 
Upvote 0
Of course you will have to work around to put your own parameters.

HTML:
Option Explicit 
 
Sub PrintWordDoc() 
    Dim oWord As Object 
    Dim sPath As String 
    Dim iCnt  As Integer 
     
     'Path to Cover.doc in same folder as workbook
    sPath = ThisWorkbook.Path & Application.PathSeparator & "Cover.doc" 
     
     'Ask copy count
    iCnt = Val(InputBox("How many copies", "Print Word doc", 1)) 
     
     'If any
    If iCnt >= 1 Then 
         
         'Create word application
        Set oWord = CreateObject(Class:="Word.Application") 
         
         'Open document sPath en printout wanted copies
        With oWord.Documents.Open(sPath) 
            .PrintOut Background:=False, Copies:=iCnt 
            .Close False 
        End With 
         
         'Quit word application
        oWord.Quit False 
    End If 
     
     'Clean up
    Set oWord = Nothing 
End Sub
 
Upvote 0
Thanks again Tropix100.

Will the code fit into a command button or does it go somewhere else?

Craig
 
Upvote 0
It's still trying to find the file, it finds the folder but it just doesn't seem to want to open it so it states unable to find document.

Any ideas.

Thanks for the help so far.

Craig
 
Upvote 0
I must be missing soemthing because I cannot work out how the code is looking at the title in cell B4, B5, B6 etc.

Thanks again.

Craig.
 
Upvote 0
You will have to change the path to reflect the contents of the cell that is the file you want to print.

</pre>
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top