'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:
You do not have path separator "\" at the end of your path.

Same 429 error code.

Code:
Sub SaveAs()

    Dim Filename As String


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


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


    ThisWorkbook.SaveAs Path & Filename


End Sub
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
One more thing - maybe in the filename you have one or more of the characters that are not allowed in the filename.

The name is cell B1 is...

Perspective L

No special characters other than a "space" between Perspective and L.
 
Upvote 0
Another thing, saving as XLSM you may need to specify it is a macro enabled workbook format.

Let me know the result of the code I posted before.
 
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

CTRL G. I don't know if this is an output of what you had me run. In fact, when I click run, nothing seems to happen. When I click some other macro, it runs.

Folder Exists
Perspective L 2015-01-26.xlsm
Folder Exists
Perspective L 2015-01-26.xlsm
Folder Exists
Perspective L 2015-01-26.xlsm
 
Last edited:
Upvote 0
Another thing, saving as XLSM you may need to specify it is a macro enabled workbook format.

Let me know the result of the code I posted before.

When I hit run, nothing seems to happen. Also, should I place a "\" right after Results in the code you posted for me? I tried both with and without the "\" right after the Results word.
 
Last edited:
Upvote 0
Try this:

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\"
    ActiveWorkbook.SaveAs Filename:=MyPath & MyFilename, FileFormat:=xlOpenXMLWorkbookMacroEnabled
End Sub
 
Upvote 0
When I hit run, nothing seems to happen. Also, should I place a "\" right after Results in the code you posted for me?
No those results you posted were fine :). All it does is send output to that debug window. It appears to do nothing unless you have that window open
 
Upvote 0
Try this:

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\"
    ActiveWorkbook.SaveAs Filename:=MyPath & MyFilename, FileFormat:=xlOpenXMLWorkbookMacroEnabled
End Sub

Wow, you're amazing. It saved to the directory perfectly. Man, I don't know how else to thank you. Thank you so much :D I spent all day trying to fix this (now 5:15PM). Now I can go home ^_^
 
Upvote 0

Forum statistics

Threads
1,215,400
Messages
6,124,702
Members
449,180
Latest member
craigus51286

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