VBA - copy from a word doc to Notes and send it - tables looks bad after receiving mail.

LuDatz

New Member
Joined
Mar 8, 2022
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
Good Evening!,


I am an VBA newbie and need some help.


I am writing a small script that should help me. Now i have some trouble with sending an email via IBM Notes.
My script opens a word doc. and copy the whole document to the clipboard. After that it opens an new Notes Mail Document and paste the copied thing. That Word docment has tables. After pasting the clipboard everything looks good. But if you receive the Email the lines of the vertical tables ann other frames are lost.

If I open a new IBM notes mail manually and paste the clippboard by pressing Strg+V and send them everything is fine. I get an email with the wright tables. So it seems that the clipboard has copied the whole tables.

In this case it have to be a problem with notes document opening procedure.

With this code the Notes Email has to be open - otherwise it won´t work. Is it possible to check if it allready oppen and otherwise it will open an new instance and document?... But thats not the main problem... first i have to fix the bad tables thing and then i will see.


I note shure if the first lines the right ones beacause I made a picture of the code during my work and now it is evening and i am at home and have to write it down form the picture. The first lines were cut of... I try to reconstruct them but it could be wrong.


Here is a picture how the table looks in the received email - A lot of table frames were lost.

bad_tables.JPG



VBA Code:
Public Sub COPY_PASTE_CLIPPBOARD_NOTES_EMAIL ()

Dim NUIWorkSpace As Object
Dim NUIDocument As Object
Dim wdApp as Word.Application
Dim wdDoc as Word.Document
Dim wdRage as Word.Range

set wdApp = CreateObject ("Word.Application")
with wdapp
Set wdDoc = .Documents.add ("U:\XYZ\wordfile.docx")
. Visible = true
End With

Set wdRange = wdDoc.Range
wdRange.WholeStory
wdRange.Copy

With ActiveSheet
ToEmail = "xyz@mail.com"
CCEmail = ""
BCCEmail = ""
Subject ="xyz"
End With

Set NUIWorkspace = CreateObject ("Notes.NotesUIWorkspace"]

'Create an email using the Notes UI

NUIWorkspace.ComposeDocument , , "Memo"

Do

Set NUIDocument = NUIWorkspace.CurrentDocument
DoEvents
Loop While NUIDocument is Nothing 

With NUIDocument

.FieldSetText "EnterSendTo", ToEmail
.FieldSetText "EnterCopyTo", CCMail
.FieldSetText "EnterBlindCopyTo", BCCEmail
.FieldSetText "Subject", Subject

.GoToField "Body"
.Paste
Application.CutCopyMode= False
'.Send
'.Close

End With

Set NUIWorkspace=Nothing
Set NUIDocument =Nothing
wdApp.Quit SaveChanges:=False
Set wdApp = Nothing
Set wdDoc = Nothing
Set wdRange = Nothin
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,224,812
Messages
6,181,094
Members
453,021
Latest member
Justyna P

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