save as button to a patch

wvanroy

New Member
Joined
Mar 15, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
HI,

I have a code here,

Sub FileNameAsCellContent()
Dim FileName As String
Dim Path As String
Application.DisplayAlerts = False
Path = "J:\123\"
FileName = Range("B1").Value & ("-") & Range("B2").Value & ".xlsx"
ActiveWorkbook.SaveAs Path & FileName, xlOpenXMLWorkbook
Application.DisplayAlerts = True
ActiveWorkbook.Close
End Sub

can i after the path 123 make a range like the filename,
that he look in the cell for where to save?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Some thing like
VBA Code:
Path = "J:\" & "123" & Range("B3").Value & "\"
Or
VBA Code:
Path = "J:\" & Range("B3").Value & "\"
 
Upvote 0
Sub FileNameAsCellContent()
Dim FileName As String
Dim Path As String
Application.DisplayAlerts = False
Path = "J:\orders" & Range("B1").Value & "\" & internaldocs
FileName = Range("BJ1").Value & ("-") & Range("B2").Value & ".xlsx"
ActiveWorkbook.SaveAs Path & FileName, xlOpenXMLWorkbook
Application.DisplayAlerts = True
ActiveWorkbook.Close
End Sub


if i do this
ActiveWorkbook.SaveAs Path & FileName, xlOpenXMLWorkbook this line gives an error
 
Upvote 0
Missed " "
Path = "J:\orders" & Range("B1").Value & "\" & "internaldocs"
 
Upvote 0
Missed " "
Path = "J:\orders" & Range("B1").Value & "\" & "internaldocs"
Sub FileNameAsCellContent()
Dim FileName As String
Dim Path As String
Application.DisplayAlerts = False
Path = "J:\orders" & Range("B1").Value & "\" & "internaldocs"
FileName = Range("BJ1").Value & ("-") & Range("B2").Value & ".xlsx"
ActiveWorkbook.SaveAs Path & FileName, xlOpenXMLWorkbook
Application.DisplayAlerts = True
ActiveWorkbook.Close
End Sub
 
Upvote 0
Try this
VBA Code:
ActiveWorkbook.SaveAs Path & FileName
 
Upvote 0
problem was the \

Sub FileNameAsCellContent()
Dim FileName As String
Dim Path As String
Application.DisplayAlerts = False
Path = "J:\orders\" & Range("B1").Value & "\internaltechdoc"
FileName = Range("B1").Value & ("-") & Range("B2").Value & ".xlsx"
ActiveWorkbook.SaveAs FileName, xlOpenXMLWorkbook
Application.DisplayAlerts = True
ActiveWorkbook.Close
End Sub

but now he don't save @ the map internaltechdoc but he create the name internaltechdoc(b1)-(b2)

and he save in the map J:\orders\" & Range("B1").Value & "\
 
Upvote 0
problem was the \

Sub FileNameAsCellContent()
Dim FileName As String
Dim Path As String
Application.DisplayAlerts = False
Path = "J:\orders\" & Range("B1").Value & "\internaltechdoc"
FileName = Range("B1").Value & ("-") & Range("B2").Value & ".xlsx"
ActiveWorkbook.SaveAs FileName, xlOpenXMLWorkbook
Application.DisplayAlerts = True
ActiveWorkbook.Close
End Sub

but now he don't save @ the map internaltechdoc but he create the name internaltechdoc(b1)-(b2)

and he save in the map J:\orders\" & Range("B1").Value & "\
Sub FileNameAsCellContent()
Dim FileName As String
Dim Path As String
Application.DisplayAlerts = False
Path = "J:\orders\" & Range("B1").Value & "\internaltechdoc"
FileName = Range("B1").Value & ("-") & Range("B2").Value & ".xlsx"
ActiveWorkbook.SaveAs Path & FileName, xlOpenXMLWorkbook
Application.DisplayAlerts = True
ActiveWorkbook.Close
End Sub


but now he don't save @ the map internaltechdoc but he create the name internaltechdoc(b1)-(b2)

and he save in the map J:\orders\" & Range("B1").Value & "\
 
Upvote 0

Forum statistics

Threads
1,212,934
Messages
6,110,762
Members
448,295
Latest member
Uzair Tahir Khan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top