Excel VBA: submit an AI video job and poll it with Application.OnTime

An Excel macro posts a Wan 3.0 job to Sume with ServerXMLHTTP, saves the job id in a cell and re-checks status with Application.OnTime without blocking Excel.

5 min readSume
All posts

In Excel, do not loop with Sleep while a video renders; that freezes the workbook. Use Application.OnTime to call a macro again in 15 seconds, so each call reads the status once and returns. The macro posts to https://api.sume.com/v1/videos with MSXML2.ServerXMLHTTP.6.0, writes the returned job id to a cell, and keeps rescheduling until the status response says terminal (Sume jobs guide, read 2026-10-06).

A planning sheet is a good fit: one row per shot, a model and duration column, and a macro that submits each row. Each Wan 3.0 720p second is $0.125 on Sume, so a row of 5 seconds is $0.625.

What is the macro?

VBA has no built-in JSON parser, so the code finds the two fields it needs with InStr. Keep SUME_API_KEY in a Windows environment variable rather than in a cell.

Function Call_(verb$, url$, Optional body$ = "") As String
    Dim h As Object: Set h = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    h.Open verb, url, False
    h.setRequestHeader "Authorization", "Bearer " & Environ("SUME_API_KEY")
    If body <> "" Then h.setRequestHeader "Content-Type", "application/json"
    h.setRequestHeader "Idempotency-Key", "xl-" & Sheet1.Range("A1").Value
    h.send body
    Call_ = Replace(h.responseText, " ", "")
End Function

Sub Submit()
    Dim r$, p&
    r = Call_("POST", "https://api.sume.com/v1/videos", _
        "{""model"":""wan-3.0"",""prompt"":""Steam over a coffee cup"",""duration"":5,""resolution"":""720p""}")
    p = InStr(r, """id"":""") + 6
    Sheet1.Range("B1").Value = Mid(r, p, InStr(p, r, """") - p)
    Application.OnTime Now + TimeSerial(0, 0, 15), "Poll"
End Sub

Sub Poll()
    Dim r$
    r = Call_("GET", "https://api.sume.com/v1/jobs/" & Sheet1.Range("B1").Value & "/status")
    If InStr(r, """terminal"":true") > 0 Then
        Sheet1.Range("C1").Value = IIf(InStr(r, """sume_status"":""completed""") > 0, "completed", "not completed")
    Else
        Application.OnTime Now + TimeSerial(0, 0, 15), "Poll"
    End If
End Sub

What are the limits of this approach?

  • OnTime only fires while the workbook is open and Excel is idle; close it and the poll stops, but the render continues at Sume, so reopen and run Poll again with the saved id in B1.
  • The macro uses a fixed 15 second delay for brevity. Read next_poll_after_seconds from the response if you submit many rows at once.
  • ServerXMLHTTP is a Windows component; Excel for Mac needs a different HTTP route.

Does re-running the script bill a second clip?

It can if you re-run the submit step. Send a stable Idempotency-Key on POST /v1/videos (here a fixed string; in practice a row id) so a repeat returns the original job. A give-up on the client never cancels the render, so keep the job id and read it again (Sume jobs guide, read 2026-10-06).

Sources

Related posts

More in Developers

All Developers posts

Written by Sume