Hey All,
I am using the GetSaveFileName API and I wanted to know if there is a way to
have the 'File Name' textbox show up empty?
For example, in most Windows apps or Office apps for that matter, when one
does a 'Save As', the cursor is placed in the 'File Name' textbox but the
textbox is empty vs. having all of the placeholder character spaces that the
GetSaveFileName defaults to because of the lpstrFile value inside the
OPENFILENAME structure.
Any advice?
Thanks,
TC
PeterD - 07 Apr 2008 13:56 GMT
>Hey All,
>
[quoted text clipped - 12 lines]
>
>TC
Like setting:
lpstrFile = chr$(0) ' set file name to null length string.
have you tried this?
TC - 07 Apr 2008 14:39 GMT
Hey Peter,
Yes.
The problem with this approach is that it does not leave any space in the
buffer for the new actual filename.
The actual textbox on the FileSave dialog needs to be reset.
Thanks,
TC
>>Hey All,
>>
[quoted text clipped - 20 lines]
>
> have you tried this?
Dave O. - 07 Apr 2008 15:04 GMT
try:
.lpstrFile = vbnullchar & space(259)
.nMaxFile = Len(.lpstrFile)
Regards
Dave O.
> Hey All,
>
[quoted text clipped - 12 lines]
>
> TC
TC - 07 Apr 2008 15:23 GMT
Thanks Dave!
Just what I needed ;-)
> try:
>
[quoted text clipped - 20 lines]
>>
>> TC
Thorsten Albers - 07 Apr 2008 17:15 GMT
TC <getmyemails2@yahoo.com> schrieb im Beitrag
<u7L959ImIHA.1280@TK2MSFTNGP05.phx.gbl>...
> I am using the GetSaveFileName API and I wanted to know if there is a way to
> have the 'File Name' textbox show up empty?
> For example, in most Windows apps or Office apps for that matter, when one
> does a 'Save As', the cursor is placed in the 'File Name' textbox but the
> textbox is empty vs. having all of the placeholder character spaces that the
> GetSaveFileName defaults to because of the lpstrFile value inside the
> OPENFILENAME structure.
> Any advice?
When you have to provide an >empty< buffer to a non-VB function which
(unlike VB) uses NULL terminated strings before passing the buffer to the
function you should initialize it to NULL bytes instead of spaces. I.e.
instead of
MyBuffer$ = Space$(260)
use
MyBuffer$ = String$(260, vbNullChar)
This prevents errors on the function's side and makes much more sense
within the context of the function.

Signature
----------------------------------------------------------------------
THORSTEN ALBERS Universität Freiburg
albers@
uni-freiburg.de
----------------------------------------------------------------------