Runtime Error 432

  • Thread starter Philippe Perrault
  • Start date
P

Philippe Perrault

I have a database report that is exported to Microsoft excel. Everything is
working fine up to this line of code: Set XlBook = GetObject(FNAME)

The code to define FNAME is as follows.
strFilter = ahtAddFilterItem(strFilter, "Microsoft Office Excel Files(*.xls)
", "*.xls")
FNAME = ahtCommonFileOpenSave(Filter:strFilter, OpenFile:=False,
DialogTitle:="Save file as:", Flags:=ahtOFN_HIDEREADONLY)
If FNAME = "" Then
Exit Sub
End If

All of this code works fine, a dialog box opens and I select a path and
enter a file name. All the code runs fine up to this point: Set XlBook =
GetObject(FNAME) where I get the Runtime Error 432.

Appricate any assisstance.
 
T

Tom van Stiphout

On Thu, 4 Dec 2008 15:57:01 -0800, Philippe Perrault

Error 432 = File name or class name not found during Automation
operation
Most likely you are trying to open an Excel workbook that does not
exist. Enhance your code like this:
FNAME = ahtCommonFileOpenSave(etc.)
If Dir$(FNAME) = "" then
Msgbox "Yo! GetObject requires an EXISTING file", vbCritical
Else
Set XlBook = GetObject(FNAME)
'etc.
End If

-Tom.
Microsoft Access MVP
 
C

clarry

Thanks Tom,
I tried enhancing the code as you suggested to ensure that the file exists
but I too am still getting the persistent error 432. My code is very similar
and when I execute the following line I get the eror:

Dim appXL As New Excel.Application
Set appXL = GetObject(strFullName, "Excel.Application")

The string variable already contains the full path & file name and the file
does indeed exist. I have also tried replacing the variable with the contents
inside quotation marks but still get the same error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top