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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conversion from VBA to VB6

Status
Not open for further replies.

johnmtb

Programmer
Jul 12, 2008
37
US
I have managed, with help to solve all of my problems, caused when I converted VBA programmes to VB6 programmes, with the exception of the following:

The programme that reads from MS Word documents, copies one of the documents, which includes a table, opens an Outlook Template file, and pastes the copied material into an e-mail body.

Below is a portion of the code, but this code does not copy the table, just text. If I comment out ‘OutlookFile.Body = WordObj.Selection, and then hit paste in Outlook, it correctly pastes the text and table.

Below is the relevant section of code at present.

Code:
Public WordObj As Word.Application
Public WordFile As Object
Public OutlookObj As Outlook.Application
Public OutlookFile As Outlook.MailItem
-
-
-

WordObj.Selection.HomeKey Unit:=wdStory
WordObj.Selection.MoveDown Unit:=wdLine, Count:=32, Extend:=wdExtend
WordObj.Selection.Copy

Set OutlookObj = CreateObject("Outlook.Application")
Set OutlookFile = OutlookObj.CreateItemFromTemplate("C:\Documents and Settings\hbcw059\Application Data\Microsoft\Templates\ICOO Bidder Approval.oft")
OutlookFile.Display

OutlookFile.Body = WordObj.Selection	‘inserts text only


I have tried all of the following, without any success:

Code:
'SendKeys ("^V")
'OutlookFile.Body = Clipboard.GetData
'OutlookFile.Body = Clipboard.GetData(vbDataObject)
'OutlookFile.Body = Clipboard.GetText(vbDataObject)
'WordObj.Selection.PasteAndFormat (wdPasteDefault)
'OutlookObj.PasteAndFormat (wdPasteDefault)
'OutlookFile.PasteAndFormat (wdPasteDefault)

Surely it must be simple, if all I have to do is hit paste, or Control-V, in Outlook?

Any help would be greatly appreciated.

john
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top