By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,327 Members | 2,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,327 IT Pros & Developers. It's quick & easy.

Select Case

P: n/a
I have created a form with 2 combo boxes. The purpose of the form is to
export CR9 reports to selected types of formats (rpt, doc,xls, etc) and
choose the destination for the report (mail, file, etc.). What is the best
method to state if selectedindex 1 and selectedindex 2 are selected so that
then the export methods is carried out according to the users wishes.

Thanks in advance!

Using VB.Net 2003

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click

Dim FileType As String
Select Case Me.cbFormat.SelectedIndex

Case 0 'PDF Format

FileType = ".pdf"

Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions

crDiskFileDestinationOptions.DiskFileName = ExportRptPath & "\" & subject &
FileType

Dim crExportOptions As ExportOptions = rpt.ExportOptions

With crExportOptions

..DestinationOptions = crDiskFileDestinationOptions

..ExportDestinationType = ExportDestinationType.DiskFile

..ExportFormatType = ExportFormatType.PortableDocFormat

End With

'execute conversion to PDF

Case 1

FileType = ".rpt"

Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions

crDiskFileDestinationOptions.DiskFileName = ExportRptPath & "\" & subject &
FileType

Dim crExportOptions As ExportOptions = rpt.ExportOptions

With crExportOptions

..DestinationOptions = crDiskFileDestinationOptions

..ExportDestinationType = ExportDestinationType.DiskFile

..ExportFormatType = ExportFormatType.CrystalReport

End With

Case 2

FileType = ".xls"

Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions

Dim excelFormatOpts As New ExcelFormatOptions

Dim crExportOptions As ExportOptions = rpt.ExportOptions

'crDiskFileDestinationOptions.DiskFileName = "c:\winaeros\reports\test.xls"

crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile

crDiskFileDestinationOptions.DiskFileName = ExportRptPath & "\" & subject &
FileType

crExportOptions.DestinationOptions = crDiskFileDestinationOptions

crExportOptions.ExportFormatType = ExportFormatType.Excel

excelFormatOpts.ExcelTabHasColumnHeadings = True

crExportOptions.FormatOptions = excelFormatOpts

Case 3

FileType = ".xls"

Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions

crDiskFileDestinationOptions.DiskFileName = ExportRptPath & "\" & subject &
FileType

Dim crExportOptions As ExportOptions = rpt.ExportOptions

Dim excelFormatOpts As New ExcelFormatOptions

With crExportOptions

..DestinationOptions = crDiskFileDestinationOptions

..ExportDestinationType = ExportDestinationType.DiskFile

..ExportFormatType = ExportFormatType.ExcelRecord

End With

excelFormatOpts.ExcelTabHasColumnHeadings = False

crExportOptions.FormatOptions = excelFormatOpts

Case 4

FileType = ".doc"

Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions

crDiskFileDestinationOptions.DiskFileName = ExportRptPath & "\" & subject &
FileType

Dim crExportOptions As ExportOptions = rpt.ExportOptions

With crExportOptions

..DestinationOptions = crDiskFileDestinationOptions

..ExportDestinationType = ExportDestinationType.DiskFile

..ExportFormatType = ExportFormatType.WordForWindows

End With

End Select

Select Case Me.cbDestination.SelectedIndex

' Case 0 'Application

'Case 1 'Disk File

'' Allow the user to save a file.

'Dim ofd As New SaveFileDialog

'Dim dr As DialogResult

'dr = ofd.ShowDialog(Me)

'If dr <> dr.Cancel Then

'Else

'MsgBox(ofd.FileName)

'End If

'Case 2 'Exchange Folder

Case 3 'Outlook

'Mail Procedure

Dim olApp As Outlook.Application

Dim olMailMessage As Outlook.MailItem

olApp = New Outlook.Application

olMailMessage = olApp.CreateItem(Outlook.OlItemType.olMailItem)

olMailMessage.Attachments.Add(ExportRptPath & "\" & subject & FileType)

olMailMessage.Subject = subject

olMailMessage.Display()

olMailMessage = Nothing

End Select

rpt.Export()

Me.Close()

End Sub
Nov 22 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.