VBA to save .xls in same folder as original document

Samahonka

New Member
Joined
Feb 17, 2019
Messages
2
Hi all,

I'm trying to use a stadard form called "Master Cleandeskform.xls", and I would like to save it in the same folder as the original document, under differend name.
Cell F3 contains the date, which is used to complete the file name.
Example: "Cleandeskform 17-02-2019.xls"

Everything is working fine, except the file is stored in the folder "My documents", which isn't the folder the original document is stored in.

This is te vba code I've used:

Sub SaveThis****()

Dim FName As String
Dim FDate As String

FName = Cleandeskform "
FDate = Sheets("Sheet1").Range("F3").Text
ThisWorkbook.SaveAs filename:=Fname & FDate

End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

wist

Board Regular
Joined
Nov 8, 2012
Messages
79
Hi, try this

Code:
Sub SaveThis()

Dim FName As String
Dim FDate As String
Dim wbpath As String

wbpath = Workbooks("Master Cleandeskform.xls").Path
FName = "Cleandeskform "
FDate = Sheets("Sheet1").Range("F3").Text
ThisWorkbook.SaveAs Filename:=wbpath & "\" & FName & FDate

End Sub
 
Last edited:

Samahonka

New Member
Joined
Feb 17, 2019
Messages
2
Thanks Wist!

I'll try that code also.

I've been coding myself also, and I came up with my own solution which did the trick:

Sub SaveThis()

Dim FDate As String

FDate = Sheets("Sheet1").Range("F4").Text
SaveAsName = ThisWorkbook.Path
ThisWorkbook.SaveAs SaveAsName & "" & "Cleandeskform " & FDate

End Sub



Hi, try this

Code:
Sub SaveThis()

Dim FName As String
Dim FDate As String
Dim wbpath As String

wbpath = Workbooks("Master Cleandeskform.xls").Path
FName = "Cleandeskform "
FDate = Sheets("Sheet1").Range("F3").Text
ThisWorkbook.SaveAs Filename:=wbpath & "\" & FName & FDate

End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,484
Messages
5,831,933
Members
430,094
Latest member
soconfused365

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