View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default GetSaveAsFilename Troubles


My guess is that you are up against a limit on the string length.
If the length of vSaveFileFilter is under 255 the dialog is displayed.
Add the line "MsgBox Len(vSaveFileFilter)" and see what you get.
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Kruncher"
wrote in message
Hello all,
I've been fighting with this for too long now, have searched the web
and groups and now come seeking your assistance.
I'm running XL2003 on XP Home.
As presented below, this snippet of code generates a runtime error 13,
type mismatch. On debug, it stops on this line:
If vFileSaveName < False Then
Hovering over the vFileSaveName shows a value of Error 2015.
Here's the kicker: if you take out the Excel 2007 line, it works just
fine. I actually have a few more file types I want to add. So I'm
wondering if there's a limit to the length of the filefilter parameter
or something. That doesn't make sense though because XL's own Save As
has much more than this (unless that's really a different dialog that
looks the same...)
I appreciate any and all help to get me over this hurdle. Completely
different alternate solutions are of course welcome as well.
Thanks,
Kruncher

Dim vSaveFileFilter As Variant
Dim vInitFile As Variant
Dim vTitle As Variant

'These are declared earlier in the module
' Dim fd As FileDialog
' Dim vFileSaveName As Variant

vTitle = "Select the export file to use."
vInitFile = ""

' this fails with run-time error 13 type mismatch
vSaveFileFilter = "Lotus 1-2-3 rel 1 (*.wks), *.wks, " & _
"Lotus 1-2-3 rel 2 (*.wk1), *.wk1, " & _
"Lotus 1-2-3 rel 3 (*.wk3), *.wk3, " & _
"Microsoft Excel (*.xls), *.xls, " & _
"Microsoft Excel 2007 (*.xlsx), *.xlsx, " & _
"Microsoft Access (*.mdb), *.mdb, " & _
"Paradox (*.db), *.db, " & _
"Web Page (*.htm;*.html), *.htm;*.html, " & _
"Adobe PDF (*.pdf), *.pdf"

vFileSaveName = _
Application.GetSaveAsFilename(vInitFile,
vSaveFileFilter, 1, vTitle)


If vFileSaveName < False Then
GetFileName = vFileSaveName
End If