Run-time error 424: Object Required

hlg0035

New Member
Joined
Sep 8, 2014
Messages
13
Getting a run time object required error with this code (bolded below) and cannot figure out why! any help would be appreciated :)

My variables for the saved word document code have previously been declared.
Dim UserId As String
UserId = Sheets("QuantienEvaluations").Range("M5").Value2

Set WrdApp = CreateObject("Word.Application")
WrdApp.Visible = True

If Sheets("QuantienEvaluations").Range("A2") = "QuantienAerisOnly" Then Set WrdDoc = WrdApp.Documents.Open("C:\Users\" & UserId & "\Desktop\Quantien With Aries Only.docx")

If Sheets("QuantienEvaluations").Range("A2") = "QuantienAerisCertus" Then Set WrdDoc = WrdApp.Documents.Open("C:\Users\" & UserId & "\Desktop\Quantien With Aeris and Certus.docx")

WrdDoc.SaveAs2 Filename:= _
"C:\Users\" & UserId & "\Desktop\ " & CustomerName & " " & City & " " & State & " " & CustomerNumber & " " & "Quantien Evaluation Agreement" & " " & Month(Now()) & "." & Day(Now()) & "." & Year(Now()) & ".docx" _
, FileFormat:=13, LockComments:=False, _
Password:="", AddToRecentFiles:=True, WritePassword:="", _
ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, CompatibilityMode:=14
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Has a Word document definitely been opened?
 
Upvote 0
If no Word document is being opened then WrdDoc is Nothing, hence the error.
 
Upvote 0
How do I change that? Sorry for the ignorance, very new to VBA and still unaware of the common syntax :)
 
Upvote 0
You need to check why this code isn't opening a Word document.
Code:
If Sheets("QuantienEvaluations").Range("A2") = "QuantienAerisOnly" Then Set WrdDoc = WrdApp.Documents.Open("C:\Users\" & UserId & "\Desktop\Quantien With Aries Only.docx")

If Sheets("QuantienEvaluations").Range("A2") = "QuantienAerisCertus" Then Set WrdDoc = WrdApp.Documents.Open("C:\Users\" & UserId & "\Desktop\Quantien With Aeris and Certus.docx")
 
Upvote 0
I have tried, I put it in a test with just that code and it worked perfectly. But when I incorproate into the program I'm trying to create I get an error.
 
Upvote 0

Forum statistics

Threads
1,222,246
Messages
6,164,807
Members
451,917
Latest member
WEB78

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