Run-Time Error '424': Object required when Saving Document

B

Brian

When I try to save a Document from a User Form Control Button I get the
following Error. It happens when you go to save the Document and hit Cancel.
If you save the Document it works perfect, but not when you Cancel it.

What I want to happen is the Message Pops Up. What did I do wrong & how do I
fix it?

Run-Time Error '424': Object required

' Save Engineering Spec 11 Control Button

Private Sub Save_Engineering_Spec_11_Click()

Dim strFile As String

strFile = "SPEC " & TEO_No_1.Value _
& Space(1) & CLLI_Code_1.Value _
& Space(1) & CES_No_1.Value _
& Space(1) & TEO_Appx_No_2.Value

bk.SaveAs Filename:=Application.GetSaveAsFilename(strFile) (Error
Message)

If FileToSave = False Then

MsgBox "The Close Method Failed, No Document Saved", , "C.E.S."

Exit Sub

End If

End Sub

Thanks
 
J

JLGWhiz

bk.SaveAs Filename:=Application.GetSaveAsFilename(strFile) (Error
Message)

Change the above line to:

Set bk = SaveAsFilename:=Application.GetSaveAsFilename(strFile)

Then add this line:

bk.Save
 
B

Brian

Now I am getting this error message "Compile Error: Syntax Error". The Set bk
Line Turned Red.


' Save Engineering Spec 11 Control Button

Private Sub Save_Engineering_Spec_11_Click()

Dim strFile As String

strFile = "SPEC " & TEO_No_1.Value _
& Space(1) & CLLI_Code_1.Value _
& Space(1) & CES_No_1.Value _
& Space(1) & TEO_Appx_No_2.Value

Set bk = SaveAsFilename:=Application.GetSaveAsFilename(strFile) (Turned
Red)

bk.Save

Exit Sub

If FileToSave = False Then

MsgBox "The Save Method Failed, No Document Saved", , "C.E. Singleton
Co. of Florida, Inc."

End If

End Sub
 
J

JLGWhiz

My error, too hasty. Correct that line to:

Set bk = Application.GetSaveAsFilename(strFile)
 
J

Jacob Skaria

Have you declared bk as a general variable and assigned that to a workbook
object..or else try

Private Sub Save_Engineering_Spec_11_Click()

Dim strFile As String
Dim bk As Workbook

Set bk = ActiveWorkbook

strFile = "SPEC " & TEO_No_1.Value _
& Space(1) & CLLI_Code_1.Value _
& Space(1) & CES_No_1.Value _
& Space(1) & TEO_Appx_No_2.Value

bk.SaveAs Filename:=Application.GetSaveAsFilename(strFile)

If FileToSave = False Then

MsgBox "The Close Method Failed, No Document Saved", , "C.E.S."

Exit Sub

End If

End Sub
 
B

Brian

It worked perfect

Thanks for your help

Jacob Skaria said:
Have you declared bk as a general variable and assigned that to a workbook
object..or else try

Private Sub Save_Engineering_Spec_11_Click()

Dim strFile As String
Dim bk As Workbook

Set bk = ActiveWorkbook

strFile = "SPEC " & TEO_No_1.Value _
& Space(1) & CLLI_Code_1.Value _
& Space(1) & CES_No_1.Value _
& Space(1) & TEO_Appx_No_2.Value

bk.SaveAs Filename:=Application.GetSaveAsFilename(strFile)

If FileToSave = False Then

MsgBox "The Close Method Failed, No Document Saved", , "C.E.S."

Exit Sub

End If

End Sub
 
B

Brian

Have you ever dealt with Progress Bars? I have a post "Help with setting
Progress Bar" 5 post down.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top