0

I know how to export to pdf using Crystal Report, but I don't want to preset file path, I want users can choose file path (and file name) when clicking Export button.

Do you know how to do that ?

Thank you very much,

Tai

taibc
  • 897
  • 2
  • 15
  • 39

2 Answers2

1

Prompting the user for a save location would be something you'd implement as part of your app - this related question provides some answers on how to do that. Then, you'd just supply the path from the dialog to the Crystal Reports export API so it saves to that location.

Community
  • 1
  • 1
Krease
  • 15,805
  • 8
  • 54
  • 86
1

Here is a partial code in my project. I hope it helps.

    Dim saveFileDialog1 As New SaveFileDialog()
    'saveFileDialog1.InitialDirectory = My.Computer.FileSystem.CurrentDirectory

    saveFileDialog1.Filter = "PDF files (*.PDF)|*.PDF"
    saveFileDialog1.FilterIndex = 1
    saveFileDialog1.RestoreDirectory = True
    If saveFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
        Try
            'Here is where you write the file 

        Catch Ex As Exception
            'MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)

        Finally
            ' Check this again, since we need to make sure we didn't throw an exception on open. 
        End Try
    End If
uqji
  • 195
  • 1
  • 10