Skip to content

CREATEOBJECT() works with COM objects but fails with Excel.Application and Word.Application #18

Open

Description

@geosyscr-oss

COM objects and Office Automation

I am testing FoxDev Studio with existing Visual FoxPro 9 code.

I found that CREATEOBJECT() works correctly with several COM objects, but it fails when creating Microsoft Office Automation objects.

Working COM objects

The following tests were performed independently in a test form:

LOCAL oShell

oShell = CREATEOBJECT("WScript.Shell")

IF VARTYPE(oShell) = "O"
    MESSAGEBOX("WScript.Shell created correctly.")
ENDIF

Result: Works correctly.

I also tested:

LOCAL oFSO

oFSO = CREATEOBJECT("Scripting.FileSystemObject")

IF oFSO.FileExists("C:\FoxDevPruebas\RevisarComprobantes\Massai001.xlsx")
    MESSAGEBOX("The file exists.")
ENDIF

Result: Works correctly.

I also tested:

LOCAL oADO

oADO = CREATEOBJECT("ADODB.Connection")

IF VARTYPE(oADO) = "O"
    MESSAGEBOX("ADODB.Connection created correctly.")
ENDIF

Result: Works correctly.

Microsoft Office COM objects

However, this:

LOCAL oExcel

oExcel = CREATEOBJECT("Excel.Application")

returns:

0x80004002 | Interface not supported

The same happens with Microsoft Word:

LOCAL oWord

oWord = CREATEOBJECT("Word.Application")

Result:

0x80004002 | Interface not supported

Both tests were performed independently in separate buttons on a test form, so the error is not related to my application code.

Additional file I/O tests

I also tested:

LOCAL lcArchivo, lnArchivo

lcArchivo = "C:\FoxDevPruebas\RevisarComprobantes\prueba.txt"

lnArchivo = FCREATE(lcArchivo)

=FWRITE(lnArchivo, "Primera línea" + CHR(13) + CHR(10))
=FWRITE(lnArchivo, "Segunda línea" + CHR(13) + CHR(10))
=FWRITE(lnArchivo, "Tercera línea" + CHR(13) + CHR(10))

=FCLOSE(lnArchivo)

Result: Works correctly.

Environment

FoxDev Studio version:

0.1.0-nightly.20260924.ebf7e0f-win-x64

Visual FoxPro 9 code:

CREATEOBJECT("Excel.Application")

works correctly in VFP9 on the same computer.

I am reporting this because COM itself appears to be working, while Excel.Application and Word.Application return 0x80004002. I would like to know whether Office Automation is currently unsupported, or if there is an additional configuration or requirement for Office COM objects in FoxDev Studio.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions