PDA

View Full Version : Solved: caption SaveAs location



av8tordude
03-27-2011, 09:57 AM
Is it possible to capture the selected location from a SaveAs dialogue box when downloading a file and insert that information into a textbox>

BrianMH
03-27-2011, 10:46 AM
Sub test()
Dim savepath
savepath = Application.GetSaveAsFilename
TextBox1.Value = savepath

End Sub

av8tordude
03-27-2011, 11:00 AM
Public Declare Function DoFileDownload Lib "shdocvw.dll" _
(ByVal lpszFile As String) _
As Long

Sub sDownloadHTTP(strURL As String)
strURL = StrConv(strURL, vbUnicode)
DoFileDownload (strURL)
End Sub

Sub AutoDownloadIntranetFile()
sDownloadHTTP "http://www.mywebsite.com//Files/file.xls"
End Sub



Well, I'm tried that, but since I'm calling the SaveAs dialogue box via a code, how do i get from there?

mikerickson
03-27-2011, 01:32 PM
Immediatly after the SaveAs has been performed, ActiveWorkbook.Path should get you where the newly named file is to be found.

Paul_Hossler
03-27-2011, 01:53 PM
Maybe you can use the FileDialog object

I've never tried using it on another file, but maybe you can get it to do what you want


Sub MyFileSaveAs()

Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogSaveAs)
With fd
'Use the Show method to display the File Picker dialog box and return the user's action.
'The user pressed Save
If .Show = -1 Then
MsgBox "The path is: " & .SelectedItems(1)
'The user pressec Cancel
Else
MsgBox "Canceled"
End If

End With
'Set the object variable to Nothing.
Set fd = Nothing
End Sub


Paul