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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

mohadin

Well-known Member
Joined
Mar 22, 2015
Messages
1,091
Office Version
  1. 2013
Platform
  1. Windows
Some thing like
VBA Code:
Path = "J:\" & "123" & Range("B3").Value & "\"
Or
VBA Code:
Path = "J:\" & Range("B3").Value & "\"
 

wvanroy

New Member
Joined
Mar 15, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
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
 

mohadin

Well-known Member
Joined
Mar 22, 2015
Messages
1,091
Office Version
  1. 2013
Platform
  1. Windows
Missed " "
Path = "J:\orders" & Range("B1").Value & "\" & "internaldocs"
 

wvanroy

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

ADVERTISEMENT

Missed " "
Path = "J:\orders" & Range("B1").Value & "\" & "internaldocs"
yeah i'll try this but also its giving a fault.
 

wvanroy

New Member
Joined
Mar 15, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
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
 

mohadin

Well-known Member
Joined
Mar 22, 2015
Messages
1,091
Office Version
  1. 2013
Platform
  1. Windows

ADVERTISEMENT

Try this
VBA Code:
ActiveWorkbook.SaveAs Path & FileName
 

wvanroy

New Member
Joined
Mar 15, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
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 & "\
 

wvanroy

New Member
Joined
Mar 15, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
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 & "\
 

Watch MrExcel Video

Forum statistics

Threads
1,129,825
Messages
5,638,551
Members
417,034
Latest member
Jigneshbharati

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
Top