View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
JHop JHop is offline
external usenet poster
 
Posts: 10
Default Compile Error: variable not defined

Thanks for this additional info. I'll file it away for possible future use.
But the solution to my problem turned out to be different. Once I got the
exact location of the break from the user, it was easy to Google and fix. In
another news group I learned that the Excel constant xlSortNormal was not
available in Excel 2000 and earlier. (I had added a new sort routine and got
the Sort statement from the macro recorder, which included
"DataOption1:=xlSortNormal")
--
Judy Hopkins


"OssieMac" wrote:

Hi again Judy,

I have just found something else that was giving me a problem and returns
the same error you are getting so thought I should share it with you.

The below code example directly out of xl2007 VBA helps demonstrate it.
(Slightly different to the example in xl2002 but principle is the same.)

For the following code to work you must select Tools- References in the VBA
Editor and check Microsoft Office n.0 Object Library
Where
n = 12 for xl2007
n = 11 for xl2003
n = 10 for xl2002
n = 9 for xl2000

If the above is not checked, then you get the error with msoFileDialogOpen
and even if you declare that variable, the code still fails.

In xl2002 I found that it was necessary to close Excel and re-open it after
selecting the option before it would work. In xl2007 this was not necessary.

Sub UseFileDialogOpen()

Dim lngCount As Long

' Open the file dialog
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = True
.Show

' Display paths of each file selected
For lngCount = 1 To .SelectedItems.Count
MsgBox .SelectedItems(lngCount)
Next lngCount

End With

End Sub


--
Regards,

OssieMac