'ThisWorkbook.SaveAs Path & Filename' getting RUN-TIME ERROR 429

betapeg

New Member
Joined
Jun 19, 2013
Messages
35
The following code is designed to save an excel file by naming it whatever is in cell B1 & today's date to the specified directory. The code stops at the line colored red and returns a "RUN-TIME ERROR 429 - ActiveX COMPONENT CAN'T CREATE OBJECT". I am assuming a missing dll or something in Tools - References not being checked, but dunno how to fix dll or what needs to be checked in References. Any help would be much appreciated.

==============================================

Sub SaveAs()

Dim Filename As String

Filename = Sheets("MODEL").Range("B1").Text
Filename = Filename & " " & Format(Date, "yyyy-mm-dd") & ".xlsm"

Path = "C:\Users\Name\Documents\Save Here\Results\"

ThisWorkbook.SaveAs Path & Filename

End Sub
 
Last edited:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
What is in cell B1 on the sheet "MODEL"?

I also wouldn't use variables like Path and Filename as they are reserved words and will give you issues, make them MyFileName and MyPath. Also don't forget to dim Path (Or MyPath as I suggested)
 
Upvote 0
Can you take my code and change it as you suggested? I can change Filename and Path to what you said, but kind of don't understand the dim Path.

Cell B1 has the name of the data set. The formula inside of cell B1 is

=DATA!A1

The DATA worksheet is nothing but values.
 
Upvote 0
I thought that might have been the issue, but double-checked, triple-checked the path and it is correct. This code was actually working perfectly a couple days ago.
 
Upvote 0
What is in cell B1 on the sheet "MODEL"?

I also wouldn't use variables like Path and Filename as they are reserved words and will give you issues, make them MyFileName and MyPath. Also don't forget to dim Path (Or MyPath as I suggested)

Tried this out as you said. Still getting the 429 error.

Code:
Sub Test()

    Dim MyFilename As String


    MyFilename = Sheets("MODEL").Range("B1").Text
    MyFilename = MyFilename & " " & Format(Date, "yyyy-mm-dd") & ".xlsm"


    MyPath = "C:\Users\Nathan\Documents\Variable Annuities\Results"


    ThisWorkbook.SaveAs MyPath & MyFilename




End Sub
 
Upvote 0
Tried this out as you said. Still getting the 429 error.

Code:
Sub Test()

    Dim MyFilename As String


    MyFilename = Sheets("MODEL").Range("B1").Text
    MyFilename = MyFilename & " " & Format(Date, "yyyy-mm-dd") & ".xlsm"


    MyPath = "C:\Users\Nathan\Documents\Variable Annuities\Results"


    ThisWorkbook.SaveAs MyPath & MyFilename




End Sub

You do not have path separator "\" at the end of your path.
 
Upvote 0
Please run this for me:

Code:
Sub Test()
    Dim MyPath as string, MyFilename As String
    MyFilename = Sheets("MODEL").Range("B1").Text & " " & Format(Date, "yyyy-mm-dd") & ".xlsm"
    MyPath = "C:\Users\Nathan\Documents\Variable Annuities\Results"
	If Not Dir(MyPath, vbDirectory) = vbNullString then
		debug.print "Folder Exists"
	Else
		debug.print "Folder does NOT exist"
	End if
	debug.print MyFileName
'    ThisWorkbook.SaveAs MyPath & MyFilename
End Sub

then enter the debug window with CTRL-G and copy the results then paste into a reply
 
Upvote 0
One more thing - maybe in the filename you have one or more of the characters that are not allowed in the filename.
 
Upvote 0

Forum statistics

Threads
1,214,780
Messages
6,121,523
Members
449,037
Latest member
tmmotairi

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