SaveAs ilename in Current Directory

ilikered100

New Member
Joined
May 29, 2013
Messages
46
I'm having trouble with the following code. It works perfectly, except that it adds the name of the parent folder at the beginning of the SaveAs filename.

The SaveAs file name should be "ParsedInfoData.xlsx", but it is saving as "ParsersParsedInfoData.xlsx". The name of the folder these files reside in is "Parsers" which is being added on to the beginning of the file name.

Any idea on how to get it to just Save As "ParsedInfoData.xlsx"

Here's my code:

-------

Sub CreateNewWorkbook()


Dim NewWorkBook As Workbook
Dim folderPath As String


Workbooks("InfoParser.xlsm").Activate
folderPath = ThisWorkbook.Path


Set NewWorkBook = Workbooks.Add
NewWorkBook.SaveAs Filename:=folderPath & "ParsedInfoData.xlsx"

MsgBox "Your Parsed data has been saved in the current folder/directory in which you are working"


End Sub

-----


Thank you,
Carolyn
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I'm having trouble with the following code. It works perfectly, except that it adds the name of the parent folder at the beginning of the SaveAs filename.

The SaveAs file name should be "ParsedInfoData.xlsx", but it is saving as "ParsersParsedInfoData.xlsx". The name of the folder these files reside in is "Parsers" which is being added on to the beginning of the file name.

Any idea on how to get it to just Save As "ParsedInfoData.xlsx"

Here's my code:

-------

Sub CreateNewWorkbook()


Dim NewWorkBook As Workbook
Dim folderPath As String


Workbooks("InfoParser.xlsm").Activate
folderPath = ThisWorkbook.Path


Set NewWorkBook = Workbooks.Add
NewWorkBook.SaveAs Filename:=folderPath & "ParsedInfoData.xlsx"

MsgBox "Your Parsed data has been saved in the current folder/directory in which you are working"


End Sub

-----


Thank you,
Carolyn
Code:
[COLOR=#333333]Set NewWorkBook = Workbooks.Add[/COLOR]
[COLOR=#333333]NewWorkBook.SaveAs Filename:=[/COLOR][I][B][COLOR=#ff0000]folderPath &[/COLOR][/B][/I][COLOR=#333333] "ParsedInfoData.xlsx"[/COLOR]

just remove folderPath &
 
Upvote 0
Code:
[COLOR=#333333]Set NewWorkBook = Workbooks.Add[/COLOR]
[COLOR=#333333]NewWorkBook.SaveAs Filename:=[/COLOR][I][B][COLOR=#ff0000]folderPath &[/COLOR][/B][/I][COLOR=#333333] "ParsedInfoData.xlsx"[/COLOR]

just remove folderPath &


Thank you so much! So simple... I spent hours trying to figure out the problem!

Carolyn
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,585
Members
448,972
Latest member
Shantanu2024

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