Close workbook after previous events

stutray

New Member
Joined
Nov 7, 2005
Messages
26
Hi all !

I have the following code but would like to close the workbook at the end :

Part 1 Unhides 2 rows
Part 2 Saves the workbook as cell B1
Part 3 Emails the new saved workbook as attachment via Lotus Notes

This is when I need to close the workbook.

I have tried various combinations of Workbook Close but have no luck.
If anyone can help I would very much appreciate it.
(Before I chew off my own arm )

Code:
Sub ClickToApproveProcess()

'Unhide Approvers Rows'
ActiveSheet.Rows("26").EntireRow.Hidden = False
ActiveSheet.Rows("28").EntireRow.Hidden = False
'end'


'SaveCopyAsSupplier'
ActiveWorkbook.SaveAs Sheets("NewSupplierRequest").Range("B1")


'Sub MailAttachAsCellName()'

Dim oSess As Object
Dim oDB As Object
Dim oDoc As Object
Dim oItem As Object
Dim direct As Object
Dim Var As Variant
Dim flag As Boolean

Set oSess = CreateObject("Notes.NotesSession")
Set oDB = oSess.GetDatabase("", "")
Call oDB.OpenMail
flag = True
If Not (oDB.IsOpen) Then flag = oDB.Open("", "")

If Not flag Then
MsgBox "Can't open mail file: " & oDB.SERVER & " " & oDB.FILEPATH
GoTo exit_SendAttachment
End If
On Error GoTo err_handler

'Building Message
Set oDoc = oDB.CreateDocument
Set oItem = oDoc.CreateRichTextItem("BODY")
oDoc.Form = "Memo"
oDoc.Subject = "New Supplier ( " & Range("B1") & " ) requires your approval *v5"
oDoc.SendTo = "Stuartluckhurst@ebgbakeries.co.uk"
oDoc.Body = ""
oDoc.postdate = Date
oDoc.SaveMessageOnSend = True

'Attaching DATABASE
Call oItem.EmbedObject(1454, "", Range("H1") & ".xls")
oDoc.visable = True
'Sending Message
oDoc.Send False
exit_SendAttachment:
On Error Resume Next
Set oSess = Nothing
Set oDB = Nothing
Set oDoc = Nothing
Set oItem = Nothing
'Done
Exit Sub
err_handler:
If Err.Number = 7225 Then
MsgBox "File doesn't exist"
Else
MsgBox Err.Number & " " & Err.Description
End If
On Error GoTo exit_SendAttachment

End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Here's the structure.

activeworkbook.close True, "C:\Test\Test.xls"
The first varilable is stating that you want to save the closing workbook, the second is of course the path.

or

workbooks("test1.xls").close True, "C:\test\test1.xls"
This one selects a specific workbook, that may not be the activeworkbook to execute the close on.

HTH
Cal
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,488
Members
448,967
Latest member
visheshkotha

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