PDA

View Full Version : Sleeper: Saveas dialog



jony
08-10-2005, 01:31 AM
hi everyone !
i have a problem for a long time:
i'm trying to open a "save as" dialog in a apecific folder (D:\2005\Temp) that the user only writes the file name and push enter.
i'm using this code:
Excel.Application.Dialogs(xlDialogSaveAs).Show "D:\2005\Temp".
the problem is that the dialog is open at the same directory that the file originally opened. (if i had the file on the desktop directory then the default directory on the "save as" dialog is the desktop).
if anyone have any suggesttions i'll be happy to hear it.
thank you.
jony.

Bob Phillips
08-10-2005, 02:08 AM
ChDrive "C:\myTest"
ChDir "C:\myTest"
Application.Dialogs(xlDialogSaveAs).Show

jony
08-10-2005, 03:25 AM
no, tried that.... not working.
thanks.

Zack Barresse
08-10-2005, 08:17 AM
Can you post what you tried (code)? Did you try stepping through your code with F8? What is the offending line? Do you receive an error? If so, what error exactly?

TheAntiGates
08-10-2005, 12:37 PM
http://support.microsoft.com/?kbid=213371

Both methods should have worked. You may be corrupt.

Admittedly a workaround, but possibly useful is

dim foo '(As Variant)
foo = Application.GetSaveAsFilename(, , , Title:="Set destination dir")
early on in your code, and .SaveAs should subsequently use its specification.

jony
08-10-2005, 09:46 PM
firefytr (http://www.vbaexpress.com/forum/member.php?u=11) vbmenu_register("postmenu_38365", true); , the code is the code i just wrote above, but here it again:


Sub SaveToFolder()
Fpath = ("D:\2005\temp\tax.xls")
Excel.Application.Dialogs(xlDialogSaveAs).Show (Fpath)
end sub

i debuged it and there is no problem apear to be and i get no error also.

TheAntiGates (http://www.vbaexpress.com/forum/member.php?u=1541), the line you wrote:

foo = Application.GetSaveAsFilename(, , , Title:="Set destination dir")
and after that: saveas....
it's seems ok, but if i type name of existin file i get a "run time" error.

i just trying to understand why the command i used won't work, it only write the file name (tax.xls) but not the path (D:\2005\temp), the path is the path that i opend the file from.

also the link to microsoft says:
To create a macro (SaveDialogFile) that will start the Save As dialog box and select a specific file name and path, use the following Visual Basic sample code:


Sub SaveDialogFile()
Application.Dialogs(xlDialogSaveAs).Show ("<drive>:\<path>\<filename>")
End Sub

TheAntiGates
08-10-2005, 10:54 PM
I really don't know - you don't seem to have any code flaws. Perhaps the problem is that D:\2005\temp doesn't exist.

jony
08-11-2005, 12:31 AM
the folder exist, i wonder if only i have this problem or anyone here succeed.