Option Explicit Sub Main Dim aiHnd As Long aiHnd = AI.NewConversation(aiGeneral) If aiHnd = 0 Then MsgBox "NewConversation failed: " & AI.LastErrorMessage, vbCritical Exit Sub End If If Not AI.AttachFile(aiHnd, "O:\Post\incoming.pdf", "Incoming document") Then MsgBox "AttachFile failed: " & AI.LastErrorMessage, vbCritical AI.CloseHandle aiHnd Exit Sub End If aiHnd = AI.Ask("Classify this document and extract the key data as a list.", , aiHnd) If aiHnd = 0 Then MsgBox "Submit failed: " & AI.LastErrorMessage, vbCritical Exit Sub End If Do DoEvents Loop Until AI.GetStatus(aiHnd) <> 1 If AI.GetStatus(aiHnd) = 2 Then MsgBox AI.GetResultStr(aiHnd), vbInformation, "Classification" Else MsgBox "<span style='color: #004080; font-weight: bold;'>Error</span>: " & AI.GetErrorMessage(aiHnd), vbCritical End If AI.CloseHandle aiHnd End Sub
|