Hi, I've got a total of 3 files I'm working and I want to save one of them in the current folder.
For starters, I am brand new to writing VBA so I'm sure this is all wrong.
My process starts with copying a master file called "template" into a customer's folder, the customer's excel file will already be in it, and then I'll open these two, do my thing then I need to save it a new workbook in this folder. I've got a command to open a new workbook, copy a tab into it and then SaveAs the name in this current folder I'm using.
I had done some Googling trying to find this answer and saw someone mention the activeworkbook.path method above but it just saves into "My Documents" on my desktop.
I will be on my shared server for our department, attempting to save into a specific customer's folder.
To clarify, I will command to open new workbook, copy data into this new workbook then SaveAs whatever name in the current folder I'm using where these other two files I'm using are. And it's different every time so I can't use the same path. Customer 1 can start with an A and have their own folder and Customer 2 might start with F and have their own folder. With sub folders as well.
Any help on this?
For starters, I am brand new to writing VBA so I'm sure this is all wrong.
My process starts with copying a master file called "template" into a customer's folder, the customer's excel file will already be in it, and then I'll open these two, do my thing then I need to save it a new workbook in this folder. I've got a command to open a new workbook, copy a tab into it and then SaveAs the name in this current folder I'm using.
VBA Code:
Sub NewPage()
Dim newwb As Workbook
Dim newpage As String
Dim relativepath As String
Set newwb = Workbooks.Add
newpage = "Example Name"
relativepath = ActiveWorkbook.Path & Application.PathSeparator & ActiveWorkbook.Name
ActiveWorkbook.SaveAs Filename:=newpage
Workbooks("Template").Sheets("Example").Copy _
Before:=newwb.Sheets(1)
'this creates the new workbook and says where to place it
Application.DisplayAlerts = False
Worksheets("Sheet1").Delete
Application.DisplayAlerts = True
End Sub
I had done some Googling trying to find this answer and saw someone mention the activeworkbook.path method above but it just saves into "My Documents" on my desktop.
I will be on my shared server for our department, attempting to save into a specific customer's folder.
To clarify, I will command to open new workbook, copy data into this new workbook then SaveAs whatever name in the current folder I'm using where these other two files I'm using are. And it's different every time so I can't use the same path. Customer 1 can start with an A and have their own folder and Customer 2 might start with F and have their own folder. With sub folders as well.
Any help on this?