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

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
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:
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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