CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 1999
    Posts
    4

    MAPI , Crystal report activex control

    Hi All,

    Please could someone tell me how to fax a crystal report from VB if a crystal report is already available (the formatting of the crystal report is important)

    Also I would like to specify the recipients fax number from within the application itself.

    Specifying MS Fax as the printer(for the crystal report control) invokes the fax dialog box but i want to avoid this.Is there a work around using MAPI or something else?

    Thanx in advance for your help
    radhika



  2. #2
    Join Date
    Apr 2000
    Posts
    5

    Faxing reports

    Hi.

    This is a solution to a problem like yours. I have reports in Access and I wan to fax them directly. I have a Client of Microsft Fax Server in my computer that send the faxes trough a server. When we use Outlook to send the reports they loose the images and other things and when we print directly to the fax printer the dialog run. May be this is not the best solution, but it work, I didn't find other.

    The main idea is change de default printer to the fax printer and create a file that the fax driver use.

    My English is not good, but I hope you understand me.

    Gnomo


    Option Explicit

    'MS Windows API Function Prototypes
    Public Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long
    Public Declare Function WriteProfileString Lib "kernel32" Alias "WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Long
    Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

    Global Const WM_WININICHANGE = &H1A
    Global Const HWND_BROADCAST = &HFFFF

    Public Function FaxReport(strReportName As String, strFaxNumber As String) As Boolean
    Dim strPrinter As String

    On Error GoTo Error_FaxReport

    FaxReport = False

    strPrinter = ChangePrinter("Fax in SERVER,FWSERVER,\\Server\Fax")
    If CreateConfigFile(strFaxNumber) Then
    DoCmd.OpenReport strReportName, acViewNormal
    FaxReport = True
    End If

    Error_FaxReport:
    strPrinter = ChangePrinter(strPrinter)
    End Function

    Public Function ChangePrinter(strPrinter As String) As String
    Dim strBuffer As String * 254
    Dim iRetValue As Long

    ' Retreive current default printer information
    iRetValue = GetProfileString("windows", "device", ",,,", strBuffer, 254)
    ChangePrinter = Left(strBuffer, InStr(strBuffer, Chr(0)) - 1)
    If WriteProfileString("windows", "device", strPrinter & Chr(0)) Then
    iRetValue = SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, ByVal "Windows")
    End If
    End Function

    Public Function CreateConfigFile(strNumber As String) As Boolean
    Dim intFileNumber As Integer

    CreateConfigFile = False

    On Error GoTo Error_CreateConfigFile

    intFileNumber = FreeFile
    Open "C:\My Documents\" & strNumber & ".ini" For Output As #intFileNumber
    Print #intFileNumber, "[Fax transport]"
    Print #intFileNumber, "SendCoverPage = N"
    Print #intFileNumber, "LocalCoverPage = N"
    Print #intFileNumber, "Name = My Name"
    Print #intFileNumber, "Fax=+n (nn) nnnnnnnnn" 'Source fax number
    Print #intFileNumber, "Company="
    Print #intFileNumber, "Mailbox="
    Print #intFileNumber, "Title="
    Print #intFileNumber, "Dept="
    Print #intFileNumber, "Office="
    Print #intFileNumber, "WorkPhone="
    Print #intFileNumber, "HomePhone="
    Print #intFileNumber, "Subject="
    Print #intFileNumber, "Note="
    Print #intFileNumber, "TimeSent= "; Format(Date, "short date") & " " & Format(Time, "Long Time")
    Print #intFileNumber, "BillingCode="
    Print #intFileNumber, "SendStart = 0"
    Print #intFileNumber, "SendEnd = 0"
    Print #intFileNumber, "CodePage = 1252"
    Print #intFileNumber, "CoverPageName="
    Print #intFileNumber, "Email = xxxxxx" 'Email to receive fax reports
    Print #intFileNumber, "Recipients = 1"
    Print #intFileNumber, ""
    Print #intFileNumber, "[Recipient0]"
    Print #intFileNumber, "Name='0 " & strNumber & "'"
    Print #intFileNumber, "Fax=0 " & strNumber
    Print #intFileNumber, "Company="
    Print #intFileNumber, "Street="
    Print #intFileNumber, "City="
    Print #intFileNumber, "State="
    Print #intFileNumber, "Zip="
    Print #intFileNumber, "Country="
    Print #intFileNumber, "Title="
    Print #intFileNumber, "Dept="
    Print #intFileNumber, "Office="
    Print #intFileNumber, "HomePhone="
    Print #intFileNumber, "WorkPhone="
    Print #intFileNumber, ""
    Close #intFileNumber
    Call WritePrivateProfileString("Fax Transport", "File", "C:\My Documents\" & strNumber & ".ini", "C:\WINDOWS\fwsrvdlg.ini")
    CreateConfigFile = True
    Error_CreateConfigFile:
    Close
    End Function




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured