Attribute VB_Name = "MdlFax" Option Explicit Private FS As New FAXCOMLib.FaxServer Private FD As New FAXCOMLib.FaxDoc Private Const MAX_COMPUTERNAME_LENGTH As Long = 31 Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long ' ·¢ËÍ´«Õæ·½·¨£¬´«ÈëÒ»¸ö·¢ËÍÎļþ·¾¶£¬»¹ÓÐÄ¿±êºÅÂë ' Dim tmpFaxFile As String ' tmpFaxFile = App.Path & "\LastFax.doc" ' m_CrReport.ExportOptions.FormatType = crEFTExactRichText ' m_CrReport.ExportOptions.DestinationType = crEDTDiskFile ' m_CrReport.ExportOptions.DiskFileName = tmpFaxFile ' m_CrReport.DisplayProgressDialog = False ' m_CrReport.Export False ' frmFax01.SendDoc = tmpFaxFile ' frmFax01.ShowForm Public Function SendFax(SendDocPath As String, SendNumber As String) As String On Error GoTo Err_Conn FS.Connect (ComputerName) ' My Computer's name On Error GoTo Err_Catch Set FD = FS.CreateDocument(SendDocPath) FD.FileName = SendDocPath FD.FaxNumber = SendNumber ' Fax number FD.DisplayName = SendNumber FD.DiscountSend = 0 FD.SendCoverpage = 0 FD.Send Err_Catch: GoTo ExitFunc Err_Conn: GoTo ExitFunc ExitFunc: If Err.Description <> "" Then SendFax = Err.Description Else SendFax = "0" End If On Error Resume Next FS.Disconnect End Function Public Function Init() As String ' ³õʼ On Error GoTo Err_Catch FS.Connect (ComputerName) ' My Computer's name Init = "0" GoTo ExitFunc Err_Catch: Init = "³õʼ´«Õæ»úʧ°Ü,ÇëÈ·¶¨ÊÇ·ñ×°Óд«Õæ»ú" Debug.Print Err.Description ExitFunc:
End Function Private Property Get ComputerName() As String Dim dwLen As Long Dim strString As String dwLen = MAX_COMPUTERNAME_LENGTH + 1 strString = String(dwLen, " ") GetComputerName strString, dwLen strString = Left(strString, dwLen) End PropertyPrivate Sub Command1_Click() Dim f As FAXCOMLib.FaxServerEnd Sub
Option Explicit
Private FS As New FAXCOMLib.FaxServer
Private FD As New FAXCOMLib.FaxDoc
Private Const MAX_COMPUTERNAME_LENGTH As Long = 31
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
' ·¢ËÍ´«Õæ·½·¨£¬´«ÈëÒ»¸ö·¢ËÍÎļþ·¾¶£¬»¹ÓÐÄ¿±êºÅÂë
' Dim tmpFaxFile As String
' tmpFaxFile = App.Path & "\LastFax.doc"
' m_CrReport.ExportOptions.FormatType = crEFTExactRichText
' m_CrReport.ExportOptions.DestinationType = crEDTDiskFile
' m_CrReport.ExportOptions.DiskFileName = tmpFaxFile
' m_CrReport.DisplayProgressDialog = False
' m_CrReport.Export False
' frmFax01.SendDoc = tmpFaxFile
' frmFax01.ShowForm
Public Function SendFax(SendDocPath As String, SendNumber As String) As String
On Error GoTo Err_Conn
FS.Connect (ComputerName) ' My Computer's name
On Error GoTo Err_Catch
Set FD = FS.CreateDocument(SendDocPath)
FD.FileName = SendDocPath
FD.FaxNumber = SendNumber ' Fax number
FD.DisplayName = SendNumber
FD.DiscountSend = 0
FD.SendCoverpage = 0
FD.Send
Err_Catch:
GoTo ExitFunc
Err_Conn:
GoTo ExitFunc
ExitFunc:
If Err.Description <> "" Then
SendFax = Err.Description
Else
SendFax = "0"
End If
On Error Resume Next
FS.Disconnect
End Function
Public Function Init() As String
' ³õʼ
On Error GoTo Err_Catch
FS.Connect (ComputerName) ' My Computer's name
Init = "0"
GoTo ExitFunc
Err_Catch:
Init = "³õʼ´«Õæ»úʧ°Ü,ÇëÈ·¶¨ÊÇ·ñ×°Óд«Õæ»ú"
Debug.Print Err.Description
ExitFunc:
End Function
Private Property Get ComputerName() As String
Dim dwLen As Long
Dim strString As String
dwLen = MAX_COMPUTERNAME_LENGTH + 1
strString = String(dwLen, " ")
GetComputerName strString, dwLen
strString = Left(strString, dwLen)
End PropertyPrivate Sub Command1_Click()
Dim f As FAXCOMLib.FaxServerEnd Sub