I have a database that I am currently upgrading and I am having just one small problem.
I have a button on a form that, when clicked, will print out the Current Form and print an Excel Document based on my current report number.
The problem I am having is that when the Workbook is open it may have more than one sheet that I wish to printout. I have used this code below:
This will work for the active sheet in the excel document but I want to print all sheets in the workbook.
Can someone please help. I have a feeling it will just be one line of code to change but I have checked around and cannot see what I am missing.
I have a button on a form that, when clicked, will print out the Current Form and print an Excel Document based on my current report number.
The problem I am having is that when the Workbook is open it may have more than one sheet that I wish to printout. I have used this code below:
Code:
Private Sub cmdPrint_Click() Dim appexcel As Object Dim MyFile As String Set appexcel = CreateObject("Excel.Application") MyFile = Me.PR_Number DoCmd.PrintOut acSelection appexcel.Workbooks.Open "G:\MB Aerospace\Aerospace New\General Access\Problem Report\Problem Reports 2012\Concession Detail\" & MyFile & ".xlsx" appexcel.Visible = True appexcel.ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True appexcel.Quit End Sub
Can someone please help. I have a feeling it will just be one line of code to change but I have checked around and cannot see what I am missing.
Comment