Stampa Report e Massimizza






Imports Microsoft.Office.Interop



Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long


Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

'On Error Resume Next

'Dim M As Boolean = MyWord.LeggiScrivi()


FileOpen(1, MyDirPath & "\INI\Report.ini", OpenMode.Output)
PrintLine(1, "AccontiOperai") ' Nome Report
PrintLine(1, "ID = 1") ' filtro

FileClose(1)


MyAccess(False)

End Sub

Private Sub MyAccess(ByVal Stampa As Boolean)
Dim hwnd As Long

Const SW_SHOWMAXIMIZED = 3
'creo un oggetto di tipo access

Dim objAccess As New Access.Application()
'apro il db

objAccess.OpenCurrentDatabase(filepath:=TypeConn.Directory_Database, Exclusive:=False)
hwnd = objAccess.hWndAccessApp
'lo rendo visibile

Dim NomeReport As String = ""
Dim MFiltro As String = ""

If Dir(MyDirPath & "\INI\Report.ini") <> "" Then
FileOpen(1, MyDirPath & "\INI\Report.ini", OpenMode.Input)
NomeReport = LineInput(1)
MFiltro = LineInput(1)
FileClose(1)
End If




'Anteprima del report (primo argomento nome report, secondo argomento visualizzazione, terzo argomento nome del filtro, quarto argomento condizione, quinto la visualizzazione e l'ultimo l'oggetto

If Stampa = False Then
ShowWindow(hwnd, SW_SHOWMAXIMIZED)

objAccess.DoCmd.SetWarnings(False)

Try
If Len(Trim(MFiltro)) > 0 Then
objAccess.DoCmd.OpenReport(ReportName:=NomeReport, View:=Access.AcView.acViewPreview, WhereCondition:=MFiltro)
Else
objAccess.DoCmd.OpenReport(ReportName:=NomeReport, View:=Access.AcView.acViewPreview)
End If

objAccess.DoCmd.Maximize()

objAccess.Visible = True

Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
'Stampa del report:


If Len(Trim(MFiltro)) > 0 Then
objAccess.DoCmd.OpenReport(ReportName:=NomeReport, View:=Access.AcView.acViewNormal, WhereCondition:=MFiltro)
Else
objAccess.DoCmd.OpenReport(ReportName:=NomeReport, View:=Access.AcView.acViewNormal)
End If

End If

'''apertura maschera argomento nome maschera, tipo visualizzazione, terzo argomento nome del filtro, quarto argomento condizione , quinto argomento modalita' apertura, apertura della finestra e argomento

'''objAccess.DoCmd.OpenForm(FormName:="Maschera1", View:=Access.AcFormView.acNormal)



' chiudi sempre l'oggetto

objAccess = Nothing


End Sub










( stampareportemassimizza.html )- by Paolo Puglisi - Modifica del 17/12/2023