To all you Gurus out there, can you explain this?
I originally wrote a programme in Word VBA, and have converted to VB6. The programme 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.
However, it did not work, as I explained in my earlier posts. Many people provided suggestions, but none of them worked. I could paste text, but not the included table.
The other day I was unable to connect to the Internet due to work being performed on our servers. So I continued to look for possible ways to work the programme. Suddenly I got it to work, using the following code
I could not believe it, after months of experimentation, without success, it worked fine. I saved the code and created the .exe file. Tested again, same results. Great!
However, when I re-connected to the Internet, opened outlook and ran the programme again, it did not work, I had to press the “paste” button.
Since then I have discovered that it will work if I am connected, but not if I open outlook first.
Can anyone tell me why this should be the case?
Regards,
john
I originally wrote a programme in Word VBA, and have converted to VB6. The programme 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.
However, it did not work, as I explained in my earlier posts. Many people provided suggestions, but none of them worked. I could paste text, but not the included table.
The other day I was unable to connect to the Internet due to work being performed on our servers. So I continued to look for possible ways to work the programme. Suddenly I got it to work, using the following code
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")
OutlookObj.ActiveWindow
OutlookFile.Display
WordObj.Selection.PasteAndFormat (wdPasteDefault)
I could not believe it, after months of experimentation, without success, it worked fine. I saved the code and created the .exe file. Tested again, same results. Great!
However, when I re-connected to the Internet, opened outlook and ran the programme again, it did not work, I had to press the “paste” button.
Since then I have discovered that it will work if I am connected, but not if I open outlook first.
Can anyone tell me why this should be the case?
Regards,
john