У меня есть файл Excel, созданный приложением vb6, и после его сохранения я хочу, чтобы он был распечатан на принтере по умолчанию ..,
Tnx, любая помощь приветствуется.
Private Sub Command1_Click() Dim xlApp As Excel.Application Dim xlWB As Excel.Workbook Dim xlSH As Excel.Worksheet 'open excel application Set xlApp = New Excel.Application 'Open excel workbook Set xlWB = xlApp.Workbooks.Open(FileName:="C:\YourFile.xls") 'There are two ways to access specific worksheets 'By index number (the first worksheet in this case) Set xlSH = xlWB.Worksheets(1) 'or by the Sheet's Name Set xlSH = xlWB.Worksheets("TestSheet") PrintSheet xlSH, "MyFoot", "MyHead" 'Close workbook (optional) xlWB.Close 'Quit excel (automatically closes all workbooks) xlApp.Quit 'Clean up memory (you must do this) Set xlWB = Nothing Set xlApp = Nothing End Sub Sub PrintSheet(sh As Worksheet, strFooter As String, strHeader As String) sh.PageSetup.CenterFooter = strFooter sh.PageSetup.CenterHeader = strHeader sh.PrintOut End Sub
Тем не менее, чтобы ответить на ваш вопрос, вы можете использовать:
ActiveWorkbook.PrintOut Copies:=1, Collate:=True
и вы можете найти много информации здесь: http://www.exceltip.com/excel_tips/Printing_in_VBA/210.html
В любом случае, я настаиваю, вы должны принять ответыВаши предыдущие вопросы или люди не будут беспокоиться, отвечая на ваши новые.
Макс