do you know how to record macros in excel? if you do, you can get the code right away, for example...this function which works:
PHP:
Dim xl As New Excel.Application
Dim wkbk As Excel.Workbook
xl.Visible = True
Set wkbk = xl.Workbooks.Open("file loc")
xl.ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
xl.Quit
wkbk.Close
Set wkbk = Nothing
Set xl = Nothing
do you know how to record macros in excel? if you do, you can get the code right away, for example...this function which works:
PHP:
Dim xl As New Excel.Application
Dim wkbk As Excel.Workbook
xl.Visible = True
Set wkbk = xl.Workbooks.Open("file loc")
xl.ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
xl.Quit
wkbk.Close
Set wkbk = Nothing
Set xl = Nothing
i have no idea how to write this code sir. i got the code from simply opening a workbook on my machine, start recording a macro, selecting print from the file menu and then pressing OK to print the current sheet. maybe it's different on yours. do what I did, and the program will give you the code, just like it did for me
Function PrintExcelWS(strPathAndName As String)
Dim objXL As Object
Dim xlWB As Object
Set objXL = CreateObject("Excel.Application")
Set xlWB = objXL.Workbooks.Open(strPathAndName)
xlWB.PrintOut
xlWB.Close
objXL.Quit
Set xlWB = Nothing
Set objXL = Nothing
End Function
Just pass the workbook's path and name to this function and there you go...