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!

macro from Word 2000 stops in Word 2003

Status
Not open for further replies.

barcon

Technical User
May 15, 2004
12
0
0
US
I have a macro which ran fine under Word 2000. I was recently upgraded to Word 2003. The macro stops on set outlk=outlook.application. Outlk is dimmed as outlook.application. I referenced Outlook as I did originally. The IT guy applied the fix in Microsoft KB891401 but it didn't help. I have set a reference to everything I could think of but still it stops. This is the error message.

RUNTIME ERROR -2147024770(8007007E)
AUTOMATION ERROR
THE SPECIFIED MODULE COULD NOT BE FOUND

I sure would appreciate any assistance.

Barbara
 

Hi,

I'd check references in the VB Editor --

Tools/References

checked reference that are labled not available.

Skip,
[sub]
[glasses] [red]Be advised:[/red]We know Newton's 3 Laws. But did you hear about the [red]FOURTH???[/red]
Only ONE fig per cookie![tongue][/sub]
 
checked reference that are labled not available.

I found nothing but one for Media Player labeled Not Public. I checked it anyway but it didn't help. Do you think it would help to reinstall Office making sure all components are checked? I need to ask the IT guy to do it if it is a possibility.

Barbara
 
For anyone who might be looking for a solution, I found this in another forum and it worked for me.

Code:
Sub LoadOutlook()
Dim outlk as Object
Set outlk=createObject("outlook.application","localhost")
'parens are on same line as previous
End Sub

Barbara
 


If you did not create the Outlook object in the PREVIOUS verion, it would never have executed any Outlook object in Word.

???


Skip,
[sub]
[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue][/sub]
 
I have pasted the relevant code snips used below. Quite a bit was found on outlookcode forum. I have to admit that I didn't know what I was doing, and it needed to be done fairly quickly. It did work reliably until the change in Word though. It turns out that the customer may accept our normal invoices now since we have made formatting changes in them, so I might not need to fix it after all. However as a matter of interest and self-education I'd be interested in your comments.

Code:
Dim Outlk As Outlook.Application
....
'sets up the outlook parameters
Set Outlk = Outlook.Application
Set myNameSp = Outlk.GetNamespace("mapi")
Set InFolder = myNameSp.GetDefaultFolder(olFolderInbox)
Set Invoice = InFolder.Items(cnt)
.....
'Write the bodytext to a temporary file in HTML code
  'The Body property provides unformatted text only.
  'The HTMLbody property provides HTML code including the formatting
        
        Set fs = CreateObject("Scripting.FileSystemObject")
        strPath = Options.DefaultFilePath(wdTempFilePath) & "\myTempFile.html"
        Set tmpFile = fs.CreateTextFile(strPath, True)
            'get message body and write to file
            tmpFile.WriteLine (Invoice.HTMLBody)
            tmpFile.Close
 
Replace this:
Set Outlk = Outlook.Application
By this:
Set Outlk = CreateObject("Outlook.Application")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top