Save As in same directory

watabowtbob

New Member
Joined
Sep 8, 2016
Messages
2
I have this working Macro but instead of saving to a specific directory I want it to save to the same directory as the current file.

What can I plug in there that won't change the other functions
Code:
Sub saveinvwithnewname()
Dim newfn As Variant
' copy invoice to new workbook
ActiveSheet.Copy
newfn = "C:\Users\Bob\Google Drive\TAMBE\E_INVOICES\Bob\E_" & Range("k4").Value & ".xlsx"
ActiveWorkbook.SaveAs newfn, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
Increment_invoice
ThisWorkbook.Save  'Saves the workbook the macro is in.




End Sub
 
Last edited by a moderator:
Welcome to the forum.

Replace this line:
Code:
newfn = "C:\Users\Bob\Google Drive\TAMBE\E_INVOICES\Bob\E_" & Range("k4").Value & ".xlsx"
with this:
Code:
newfn = ThisWorkbook.Path & "\E_" & Range("k4").Value & ".xlsx"
 
Upvote 0

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