SaveAs File Path Method

K

kartune85

I'm having a bit of trouble with the
"Application.Dialogs(xlDialogSaveAs).Show(SvNm1)". It's been working in
my other programs but this one isn't navigating to the specified path.
I'm calling the function from within a Form, once the user clicks
'Done' it calls "Call SaveFileAs" plus rattles off a few other things.

Here is the code located in Module1:

Sub SaveFileAs()
Dim ck As Boolean
Dim SvNm1 As String
Dim fcount As String
Dim DcName As String
fcount = Range("j3")
DcName = WD1.TextBox2.Text 'WD1 = UserForm

If fcount < 33000 And fcount > 31999 Then
SvNm1 = "\\bnefile\data\Works Docket\WD\32000\" & fcount & "-"
& WD1.TextBox2.Text
ElseIf fcount < 34000 And fcount > 32999 Then
SvNm1 = "\\bnefile\data\Works Docket\WD\33000\" & fcount & "-"
& WD1.TextBox2.Text
ElseIf fcount < 35000 And fcount > 33999 Then
SvNm1 = "\\bnefile\data\Works Docket\WD\34000\" & fcount & "-"
& WD1.TextBox2.Text
ElseIf fcount < 36000 And fcount > 34999 Then
SvNm1 = "\\bnefile\data\Works Docket\WD\35000\" & fcount & "-"
& WD1.TextBox2.Text
ElseIf fcount > 35999 Then
MsgBox "Out of Range!"
Workbooks(1).Activate
Application.DisplayAlerts = False
ActiveWindow.Close
Application.DisplayAlerts = True
End If

ck = Application.Dialogs(xlDialogSaveAs).Show(SvNm1)

If ck = True Then
newName = ActiveWorkbook.Name
Else
Workbooks(1).Activate
Application.DisplayAlerts = False
mycount = Range("j3") - 1
Workbooks(1).Worksheets(2).Activate
Range("j3") = mycount
Workbooks(1).Worksheets(1).Activate
Range("j3") = mycount
Call Save
ActiveWindow.Close
Application.DisplayAlerts = True
End If
End Sub

If anyone could point me in the right direction, that would be
appreciated.

Kartune85. :confused:
 
N

Nick Hodge

If I understand you correctly, try

sFileName=Application.GetSaveAsFileName()

This assigns a filename and path to the variable and you can set an initial
filename, file type, dialog title, etc.

It does not open the file, you have to do that using the variable

ActiveWorkbook.SaveAs Filename:=sFileName

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top