El número de carta porte usado en el ejemplo es provisto por la documentación de AFIP. Aun en modo prueba los C.U.I.T. deben ser validos.
Para usar el control ActiveX en Visual Basic 5 o posterior:
Agregar al proyecto una referencia al componente WSAFIPFE
Insertar el control WSAFIPFE. Cambiar la propiedad "name" a "FE".
En el evento click de un control tipo botón insertar el siguiente código:
If Me.fe.iniciar(0, "CUIT del emisor", "ruta y nombre del certificado *.pfx", "") Then
If Me.fe.gObtenerTicketAcceso() Then
Me.fe.gCTGCuitRepresentado = "CUTI del emisor"
Me.fe.gCTGCantHoras = 1
Me.fe.gCTGCodigoCosecha = "910"
Me.fe.gCTGCodigoEspecie = "1"
Me.fe.gCTGCodigoLocalidadDestino = "12699"
Me.fe.gCTGCodigoLocalidadOrigen = "6262"
Me.fe.gCTGCuitDestinatario = "CUTI del emisor"
Me.fe.gCTGCuitDestino = "CUIT del emisor"
Me.fe.gCTGCuitRemitenteComercial = ""
Me.fe.gCTGCuitTrasnportista = "30708200286"
Me.fe.gCTGNumeroCartaPorte = "512345678"
Me.fe.gCTGPatenteVehiculo = "ABC123"
Me.fe.gCTGPesoNetoCarga = "200"
If Me.fe.gSolicitarCTG() Then
Dim cNumeroCTG As String
cNumeroCTG = Me.fe.gCTGRespuestaNumeroCTG
MsgBox ("CTG obtenido " + cNumeroCTG)
If Me.fe.gConfirmarCTG("CUIT del emisor", cNumeroCTG, "512345678", "200", "30708200286") Then
MsgBox ("código transacción confirmación CTG " + Me.fe.gCTGRespuestaCodigoTransaccion)
Else
MsgBox ("Error confirmar CTG " + Me.fe.gErrorMensaje)
End If
Else
MsgBox ("Error al obtener CTG " + Me.fe.gErrorMensaje)
End If
Else
MsgBox ("Fallo de acceso " + Me.fe.UltimoMensajeError)
End If
Else
MsgBox ("Fallo al iniciar " + Me.fe.UltimoMensajeError)
End If