Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing A File Into Clipboard Using VBA 1

Status
Not open for further replies.

AZGuy82

Technical User
Apr 3, 2011
10
0
0
US
I am wondering if somebody can help me with a VBA code that would pass a file into the clipboard. So if a file exists (e.g. C:\Temp\1.xls) I would like to pass it into the clipboard so that I could paste it into a Lotus Notes email.

The following code allows me to create a Lotus Notes memo

Code:
 Dim CN, UserName, MailFile As String
    Dim workspace As Object
    Set workspace = CreateObject("Notes.NotesUIWorkspace")
    Dim session As Object
    Set session = CreateObject("Notes.NotesSession")
    CN = session.COMMONUSERNAME
    UserName = LCase(Left(Left$(CN, 1) & Right$(CN, (Len(CN) - InStr(1, CN, " "))), 8)) & ".nsf"
    Set session = Nothing
    MailFile = "mail\" & UserName

    Dim NotesUIDoc As Object
    Set NotesUIDoc = workspace.COMPOSEDOCUMENT("", "", "Memo")
    Call NotesUIDoc.FIELDSETTEXT("EnterSendTo", "Me@Me.com")
    Call NotesUIDoc.FIELDSETTEXT("EnterCopyTo", "Me2@Me.com")
    Call NotesUIDoc.FIELDSETTEXT("Subject", "Test Email")
    NotesUIDoc.GOTOFIELD "Body"

And what I'm trying to do is paste the file at C:\Temp\1.xls into the email. I have found that if I pause the code, go into Windows explorer, select 1.xls and press Ctrl+C, then run

Code:
 Call NotesUIDoc.Paste

The file gets saved into the email.
However, I am unable to find the code that will pass the file into the clipboard so that the Paste function works.

I recognize there are other ways to send Lotusnotes emails with attachment (such as with createrichtext) but the methods I've seen do not allow you to edit the email. Could anybody provide help on this?

Thanks very much
 
A starting point:
Code:
Set SA = CreateObject("Shell.Application")
Set F = SA.NameSpace("C:\Temp")
Set FI = F.ParseName("1.xls")
FI.InvokeVerb "Copy"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV - this was exactly what I needed.
Thanks very much for your help and quick response!
 
>other ways ... with createrichtext... and allow you to edit the email.
The penultimate post in thread222-766157 may be of interest; consider its written for vb6.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top