D
DS
I have this VB6 Code. Is there a way of altering it so that it works in
VBA?
Thanks
DS
Private Sub ButnGetStatus_Click()
Dim rtn As Long 'return value from function call
Dim getstatus As Long 'the status
'get the current printer status
rtn = BiGetStatus(m_hApi, getstatus)
If rtn < 0 Then
ErrMsg (rtn)
Exit Sub
End If
'call function to update the checkboxes with the current status
checkStatus (getstatus)
End Sub
Private Sub ButnPrnt_Click()
Dim Prnt As Printer
Dim nCnt As Integer
'initialize the printer that was chosen
For Each Prnt In Printers
If Prnt.DeviceName = m_PrtN Then
Set Printer = Prnt
Exit For
End If
Next
Dim I As Integer
'Get printer font all data
fntCount = Printer.fontCount
fntCount = 0
nCnt = 0
EnumFontFamilies Printer.hdc, vbNullString, AddressOf
EnumGetFontCount, fntCount
ReDim lstPrnFontTbl(fntCount)
EnumFontFamilies Printer.hdc, vbNullString, AddressOf
EnumGetFontName, nCnt
'Set default title font name
fntTitleName = TITLE_FONTA
For I = 0 To fntCount
' If Printer.Fonts(I) = TITLE_FONTA11 Then
If lstPrnFontTbl(I) = TITLE_FONTA11 Then
fntTitleName = TITLE_FONTA11
Exit For
End If
Next I
'demonstrate the printer fonts
Dim yPos As Integer
Dim tblIdx As Integer
Dim fntIdx As Integer
Dim strTit As String
Printer.Print
Printer.CurrentY = 0
Printer.ScaleMode = PIXELS
Screen.MousePointer = 11
Printer.font.name = fntTitleName
Printer.font.Size = 10
'print the title
Printer.Print PRINT_TITLE_NAME
Printer.CurrentY = Printer.CurrentY + 6
Printer.Print "Print Font Sample"
Printer.CurrentY = Printer.CurrentY + 50
nPrnYPos = Printer.CurrentY
'call the funtion to print a font sample
For tblIdx = 0 To (lstPrnFontCount - 1)
For fntIdx = 0 To fntCount
If lstPrnFontTbl(fntIdx) = lstPrnFont(tblIdx).name Then
Call PrintFontSub(lstPrnFont(tblIdx).name,
lstPrnFont(tblIdx).Size)
Exit For
End If
Next fntIdx
Next tblIdx
Printer.EndDoc
Screen.MousePointer = 0
End Sub
VBA?
Thanks
DS
Private Sub ButnGetStatus_Click()
Dim rtn As Long 'return value from function call
Dim getstatus As Long 'the status
'get the current printer status
rtn = BiGetStatus(m_hApi, getstatus)
If rtn < 0 Then
ErrMsg (rtn)
Exit Sub
End If
'call function to update the checkboxes with the current status
checkStatus (getstatus)
End Sub
Private Sub ButnPrnt_Click()
Dim Prnt As Printer
Dim nCnt As Integer
'initialize the printer that was chosen
For Each Prnt In Printers
If Prnt.DeviceName = m_PrtN Then
Set Printer = Prnt
Exit For
End If
Next
Dim I As Integer
'Get printer font all data
fntCount = Printer.fontCount
fntCount = 0
nCnt = 0
EnumFontFamilies Printer.hdc, vbNullString, AddressOf
EnumGetFontCount, fntCount
ReDim lstPrnFontTbl(fntCount)
EnumFontFamilies Printer.hdc, vbNullString, AddressOf
EnumGetFontName, nCnt
'Set default title font name
fntTitleName = TITLE_FONTA
For I = 0 To fntCount
' If Printer.Fonts(I) = TITLE_FONTA11 Then
If lstPrnFontTbl(I) = TITLE_FONTA11 Then
fntTitleName = TITLE_FONTA11
Exit For
End If
Next I
'demonstrate the printer fonts
Dim yPos As Integer
Dim tblIdx As Integer
Dim fntIdx As Integer
Dim strTit As String
Printer.Print
Printer.CurrentY = 0
Printer.ScaleMode = PIXELS
Screen.MousePointer = 11
Printer.font.name = fntTitleName
Printer.font.Size = 10
'print the title
Printer.Print PRINT_TITLE_NAME
Printer.CurrentY = Printer.CurrentY + 6
Printer.Print "Print Font Sample"
Printer.CurrentY = Printer.CurrentY + 50
nPrnYPos = Printer.CurrentY
'call the funtion to print a font sample
For tblIdx = 0 To (lstPrnFontCount - 1)
For fntIdx = 0 To fntCount
If lstPrnFontTbl(fntIdx) = lstPrnFont(tblIdx).name Then
Call PrintFontSub(lstPrnFont(tblIdx).name,
lstPrnFont(tblIdx).Size)
Exit For
End If
Next fntIdx
Next tblIdx
Printer.EndDoc
Screen.MousePointer = 0
End Sub