0% found this document useful (0 votes)
20 views2 pages

Mini Tally VBA Code AtoZ

The document outlines a VBA code for a dashboard navigation system that includes functionalities for voucher entry, ledger viewing, printing, exporting to PDF, and emailing reports. It ensures required fields are filled before saving vouchers to a worksheet, loads ledger data based on selected criteria, and provides options for print preview and PDF export. Additionally, it includes a function to send the generated report via email using Outlook.

Uploaded by

Madhu Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Mini Tally VBA Code AtoZ

The document outlines a VBA code for a dashboard navigation system that includes functionalities for voucher entry, ledger viewing, printing, exporting to PDF, and emailing reports. It ensures required fields are filled before saving vouchers to a worksheet, loads ledger data based on selected criteria, and provides options for print preview and PDF export. Additionally, it includes a function to send the generated report via email using Outlook.

Uploaded by

Madhu Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Dashboard Navigation

Private Sub btnVoucher_Click()


frmVoucherEntry.Show
End Sub

Private Sub btnLedger_Click()


frmLedgerView.Show
End Sub

Voucher Entry - Save Voucher

Private Sub btnSave_Click()


If txtDate = "" Or cboType = "" Or txtAmount = "" Then
MsgBox "Please fill all required fields", vbExclamation
Exit Sub
End If

Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Data")

Dim nextRow As Long


nextRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row + 1

ws.Cells(nextRow, 1).Value = txtDate


ws.Cells(nextRow, 2).Value = cboType
ws.Cells(nextRow, 3).Value = txtParticular
ws.Cells(nextRow, 4).Value = txtAmount
ws.Cells(nextRow, 5).Value = txtRemark

MsgBox "Voucher saved!", vbInformation


Call ClearForm
End Sub

Ledger View - Load Ledger

Private Sub LoadLedger()


Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Data")

Dim lastRow As Long


lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row

Dim i As Long
For i = 2 To lastRow
If ws.Cells(i, 2).Value = cboLedger.Value Then
lstLedger.AddItem ws.Cells(i, 1).Value
lstLedger.List(lstLedger.ListCount - 1, 1) = ws.Cells(i, 3).Value
lstLedger.List(lstLedger.ListCount - 1, 2) = ws.Cells(i, 4).Value
End If
Next i
End Sub

Print Preview & Export to PDF

Private Sub btnPrintPreview_Click()


Sheets("PrintPreview").Activate
ActiveWindow.SelectedSheets.PrintPreview
End Sub

Private Sub btnExportPDF_Click()


Dim filePath As String
filePath = ThisWorkbook.Path & "\Voucher_" & Format(Now(), "ddmmyy_hhmmss") & ".pdf"

Sheets("PrintPreview").ExportAsFixedFormat Type:=xlTypePDF, Filename:=filePath


MsgBox "PDF Exported Successfully to: " & filePath
End Sub

Email Function

Sub SendReportByEmail()
Dim outlookApp As Object
Dim outlookMail As Object
Dim filePath As String

filePath = ThisWorkbook.Path & "\Report_" & Format(Now(), "yyyymmdd_hhmmss") &


".pdf"
Sheets("PrintPreview").ExportAsFixedFormat Type:=xlTypePDF, Filename:=filePath

Set outlookApp = CreateObject("Outlook.Application")


Set outlookMail = outlookApp.CreateItem(0)

With outlookMail
.To = "example@email.com"
.Subject = "Mini Tally Report"
.Body = "Please find the attached report."
.Attachments.Add filePath
.Send
End With

MsgBox "Email Sent Successfully!"


End Sub

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy