View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chuck Waterfield Chuck Waterfield is offline
external usenet poster
 
Posts: 4
Default GetOpenFileName bug

I have a situation where I need to insert formulas containing
sheetnames, and test for situations where the sheetname may not exist
in the workbook. I had some complex code that would crash every time,
and ultimately I narrowed down the cause of the crash to the use of
the GetOpenFilename line. This simple procedure below will
demonstrate the problem. The first line works as expected. The
GetOpenFilename works as expected. But then the third line (even
though identical) returns the error Method Formula of object Range
fails. Excel then becomes unstable and will crash when I run other
procedures.

Sub TestOpen()

Range("a1").Formula = "=badsheet!a21"
strOpenName = Application.GetOpenFilename("Excel files, *.xls")
Range("a2").Formula = "=badsheet!a22"

End Sub

Im using Excel 2003. I couldn't find any information on this in the
knowledgebase. Is this a known bug, and does anyone know of a
workaround I could try? I do need to use GetOpenFileName to get the
file with the formulas, and then I do need to test if any of the
formulas contain references to sheetnames which don't exist.

Thanks for any help on this,

Chuck Waterfield