Run-time error '1004' - SaveAs VBA

Chrissyb173

New Member
Joined
Jul 21, 2015
Messages
3
Hello there!

I am hoping someone could help me!

I am trying to save a worksheet as a text file which i know is definitely possible and has been achieved by many other people but for some reason it is not working for me.

Could someone take a look at my code and let me know where i have gone wrong please?

The error occurs at the SaveAs line.

The 'Me.FolderLocation.Value' object is one that the user selects themselves in a previous step so i know for certain the the file path works and i have even quality checked this by adding a Msgbox with the full file path.

Code:
Private Sub ButtonExportLog_Click()
Dim FName As String


FName = "Timesheet Upload Log Extract " & Format(Now, "DD-MMM-YY HH-MM") & ".txt"


Workbooks.Add
ActiveSheet.Cells(1, 1) = Me.TextBox.Value
ActiveSheet.SaveAs FileName:=Me.FolderLocation.Value & FName, FileFormat:=xlText
ActiveWorkbook.Close (False)
End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
You are trying to save the ActiveSheet. Need to change it to ActiveWorkbook
 
Upvote 0
No worries, I saw it as I entered the forum and it's an error I've had many times myself :oops:
 
Upvote 0

Forum statistics

Threads
1,215,248
Messages
6,123,873
Members
449,130
Latest member
lolasmith

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