I have the following code, which prints a worksheet based on a query to get directory name, and sheet name. It works great except I only want sheet 1.
Any help on how to modify my code to get sheet 1 would be greatly appreciated.
code...
Private Sub Command12_Click()
Dim objXL As Object
Dim xlWB As Object
Dim mach_name As String
Dim tool_name As String
Dim SQL As String
Dim File_Path As String
SQL = "Select Machine_and_Tool.mach, Machine_and_Tool.tool from Machine_and_Tool"
'Open Connection and Run SQL
Dim dbConnection As New ADODB.Recordset
dbConnection.Open SQL, CurrentProject.Connection, adOpenStatic, adLockOptimistic
mach_name = dbConnection("mach").Value
tool_name = dbConnection("tool").Value
File_Path = "G:\Production\Vacuum Forming\VF Forms\Setup Sheets\" & mach_name & "\" & tool_name & ".xls"
Set objXL = CreateObject("Excel.Application")
Set xlWB = objXL.Workbooks.Open(File_Path)
xlWB.PrintOut
xlWB.Close
objXL.Quit
Err:
Set xlWB = Nothing
Set objXL = Nothing
End Sub