Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default CommonDialog Error

Hello Experts,
I have Excel 97 Pro on Win98SE.

I am trying to display CommonDialog box using following code:

Dim cdbForLST As CommonDialog
Set cdbForLST = New CommonDialog
Dim ffNo As Integer
ffNo = FreeFile()
With cdbForLST
.Filter = "GetRight URL Lists (*.lst)|*.lst|All Files (*.*)|*.*"
.FilterIndex = 1
.InitDir = "C:\My Documents"
.DialogTitle = "Save as *.lst"
.ShowSave ' execution never goes beyond this point
If .FileName < "" Then
MsgBox "OK"
' this line is for checking if execution
' reaches this point or not.
End If
End With

This code stops executing at ".ShowSave" (see comments in code) and when I
click "OK" in CommonDialog box, following error occurs:
=================================
Run-time error '20476':

Method 'ShowSave' of object 'ICommonDialog' failed
=================================
I have VB6 EE too in my computer. I have searched the help files of both,
VBA for Excel and VB6 EE, but haven't got any clue about the meaning of this
error. I have been using CommonDialog box in VB6 very successfully with same
type of code. But in VBA for Excel it is causing above mentioned error.

What is the meaning of this error?

Is newer version of CommonDialog box not compatible with VBA for Excel 97?

Thank you,
--
Syed Zeeshan Haider.
http://szh.20m.com/


-----------------------------------
Allah says to Mankind:
"Then which of the favours of your Lord will ye deny?"


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default CommonDialog Error

Hi Syed

You should not use an external component for this. Try instead:

Sub test()
Dim F As Variant
ChDrive ("C:\Temp")
ChDir ("C:\Temp")
F = Application.GetSaveAsFilename( _
InitialFilename:=Format(Date, "yyyymmdd") & ".lst", _
filefilter:="GetRight URL Lists (*.lst), *.lst, " & _
"All Files (*.*), *.*", _
filterindex:=1, _
Title:="Pick a cool location")
If F = False Then
MsgBox "You cancelled"
Else
MsgBox "let us save it as " & _
CStr(F)
End If
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please

"Syed Zeeshan Haider" skrev i melding
...
Hello Experts,
I have Excel 97 Pro on Win98SE.

I am trying to display CommonDialog box using following code:

Dim cdbForLST As CommonDialog
Set cdbForLST = New CommonDialog
Dim ffNo As Integer
ffNo = FreeFile()
With cdbForLST
.Filter = "GetRight URL Lists (*.lst)|*.lst|All Files (*.*)|*.*"
.FilterIndex = 1
.InitDir = "C:\My Documents"
.DialogTitle = "Save as *.lst"
.ShowSave ' execution never goes beyond this point
If .FileName < "" Then
MsgBox "OK"
' this line is for checking if execution
' reaches this point or not.
End If
End With

This code stops executing at ".ShowSave" (see comments in code) and when I
click "OK" in CommonDialog box, following error occurs:
=================================
Run-time error '20476':

Method 'ShowSave' of object 'ICommonDialog' failed
=================================
I have VB6 EE too in my computer. I have searched the help files of both,
VBA for Excel and VB6 EE, but haven't got any clue about the meaning of

this
error. I have been using CommonDialog box in VB6 very successfully with

same
type of code. But in VBA for Excel it is causing above mentioned error.

What is the meaning of this error?

Is newer version of CommonDialog box not compatible with VBA for Excel 97?

Thank you,
--
Syed Zeeshan Haider.
http://szh.20m.com/


-----------------------------------
Allah says to Mankind:
"Then which of the favours of your Lord will ye deny?"




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default CommonDialog Error

Thank you very much, Harald!

It worked very well.
I love simple examples like you posted. They make the complex tasks easier.

But I am still wondering why doesn't CommonDialog box work with VBA for
Excel 97 Pro?

Thanks again!
--
Syed Zeeshan Haider.
http://szh.20m.com/


-----------------------------------
Allah says to Mankind:
"Then which of the favours of your Lord will ye deny?"



"Harald Staff" wrote in message ...
Hi Syed

You should not use an external component for this. Try instead:

Sub test()
Dim F As Variant
ChDrive ("C:\Temp")
ChDir ("C:\Temp")
F = Application.GetSaveAsFilename( _
InitialFilename:=Format(Date, "yyyymmdd") & ".lst", _
filefilter:="GetRight URL Lists (*.lst), *.lst, " & _
"All Files (*.*), *.*", _
filterindex:=1, _
Title:="Pick a cool location")
If F = False Then
MsgBox "You cancelled"
Else
MsgBox "let us save it as " & _
CStr(F)
End If
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default CommonDialog Error

Hi again Syed

That is a mystery. It should in your case, since you are licensed to use it in both
runtime and designtime mode. But there are bugs in'97, and there are potential version
conflicts in all instances of external components -my very best tools recently crashed
during some "service pack". Anyway, it would probably not work on another computer or with
another user with fewer licenses and priviledges.

... a very long "I have no idea" reply :-)
--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Syed Zeeshan Haider" wrote in message
...
Thank you very much, Harald!

It worked very well.
I love simple examples like you posted. They make the complex tasks easier.

But I am still wondering why doesn't CommonDialog box work with VBA for
Excel 97 Pro?

Thanks again!
--
Syed Zeeshan Haider.
http://szh.20m.com/


-----------------------------------
Allah says to Mankind:
"Then which of the favours of your Lord will ye deny?"




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error of slope taking into account error of the data points cer144 Excel Worksheet Functions 5 July 7th 08 07:26 PM
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Error 50290: Error writing to Worksheet while using an ActiveX Control emblair3 Excel Programming 3 February 24th 04 06:03 PM


All times are GMT +1. The time now is 04:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"