• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Application.Dialogs(xlDialogSaveAs).Show Default Filename

WMR

New Member
Hello all,

My first post. I'll hope I do it right. (I am Dutch, so excuse for my English).

There is a lot to find about Application.Dialogs(xlDialogSaveAs).Show, but...

It does not seems to work in Excel 2010/2013.

Code:
MyFilename = "ABC"

Application.Dialogs(xlDialogSaveAs).Show MyFilename

This leaves the textbox Filename blanc.

Is there a solution?

Kind regards
Willem
 
Hi WMR, and welcome to the forum! :awesome:

First, nice job on writing your post, and extra points for remembering to use the CODE tags for posting VB. Very nice! :cool:

For your question, the code you posted is working fine on my machine, running WIndows 7 & Office 2010.
Code:
Sub test()
Dim MyFilename As String
MyFilename = "ABC"

Application.Dialogs(xlDialogSaveAs).Show MyFilename

End Sub
Displays this:
upload_2015-6-5_9-57-30.png

Are you getting something different? Is there more to your code perhaps?
 
Thank you very much, Luke!

I am a bit (very) stupid. I didn't try this simple code. It is working indeed. There is indeed more in my code, but I thought the Application.Dialogs(xlDialogSaveAs).Show code was the problem.

What I want is a filename with a timestamp, so:

Code:
MyFilename = "ABC" & "- " & format(Today(), "yyyy-mm-dd [hh]:mm")

But the problem seems to be the : in the filename.

Is that possible?

Kind regards
Willem
 
Hi Willem ,

The colon is not allowed in the filename part of a Windows filename.

If at all you need to use a colon , you will need to substitute the colon with lookalike characters , of which there are two :

The symbol which has the Unicode A789.

Another symbol is also similar , and its Unicode number is FF1A.

What you need to do is use the SUBSTITUTE command to replace the colon characters in the timestamp with either of these lookalikes.

Narayan
 
Narayan has hit the nail on the head regarding the issue. I'd go with either his substitution idea, or keep the time/date format simple like:
yyyy.mm.dd_hhmm
 
Back
Top