Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

VBA code to open and print doc. text files from an Excel GUI

  Asked By: Sean    Date: Jan 29    Category: MS Office    Views: 1892
  

What would be appropriate lines of code to open and print doc.,
xls.,text etc. files from an Excel GUI

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Allison Stanley     Answered On: Jan 29

For excel  and text  documents, record a macro of yourself opening and
printing to see how it is done. For word, you can use something like:

Sub WordPrint()
Dim objWord As Object
p = Application.ThisWorkbook.Path
f = p & "\" & "Test.doc"

Set objWord = CreateObject("Word.Application")
objWord.Visible = 1
With objWord
.Documents.Open Filename:=f
.ActiveDocument.PrintOut
.ActiveWindow.Close
.Quit
End With
Set objWord = Nothing
End Sub

 




Tagged: