Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Error in Loading DLL in Visual Basic program w/ MS Word macros

Posted on 2004-03-31
14
Medium Priority
?
2,728 Views
Last Modified: 2008-07-25
Hi!
I'm usually good at figuring these things out, but I am stuck. I just got a new laptop that has XP Pro and everything is a little different. I ran a program that worked fine on my old desktop computer, but seems to be missing a DLL now.

It's a VB6 program that takes data from a database and formats it to paste into Word (I have Office 2000). The error is on the line where I first use my word document, after I initialize the word.application. Here's a segment of the code:

'open up a new word document
    Dim Projects As New Word.Application
    With Projects
        .WindowState = wdWindowStateNormal
        .Documents.Add "Normal.dot", , , True
        .Visible = True
...

When I run I get an error that says Run-time error 48: Error in loading DLL. On debug, it highlights the "With Projects" line.

So I'm assuming it has to do with old references not working in XP, but I don't know how to find out which DLL is causing the problem or what I need to do to fix it.

Thanks!!
Paix120
0
Comment
Question by:paix120
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 2
  • 2
  • +1
14 Comments
 
LVL 3

Author Comment

by:paix120
ID: 10727342
p.s. I added Set Projects = New Word.Application and still get the same error, except now it's on this line. Seems to come up as soon as I try to use the word.application I created.
0
 
LVL 14

Expert Comment

by:Tommy Kinard
ID: 10727661
Hi paix120,
Try it this way

Set Projects = CreateObject("Word.Application")

HTH
dragontooth

0
 
LVL 3

Author Comment

by:paix120
ID: 10727918
nope. same error.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Accepted Solution

by:
tedunni earned 165 total points
ID: 10728297
You might have tried this, but I recently had a similar problem.  What I did was to go to Start/Programs/Microsoft Visual Studio 6/Microsoft Visual Studio 6 Tools/Depends.

Using this program "Dependency Walker", you can select a dll and it will go out and tell you what other dll's it needs.  It highlighted a couple of dll's that I needed and when I copied them into the directory that I was working on, my problem was fixed.

Good luck.

0
 
LVL 14

Expert Comment

by:Tommy Kinard
ID: 10728374
Ok is Word installed on the laptop?

dragontooth

0
 
LVL 3

Author Comment

by:paix120
ID: 10729415
Yes word is installed.

tedunni - sounds like a great idea, i've never heard of that. how do you use it? i'm not sure what dlls are in my project, so how do i know which ones to open? is there a way to tell which dlls are added when you add a reference in VB? (the DLLs are not explicitly in the code...)

thanks!
paix120
0
 

Expert Comment

by:tedunni
ID: 10732033
To be honest, I'm not too sure how to tell which dll's are added when you add a reference in VB, beside the actuall dll that is being added.  In the problem that I had, it was pretty obvious what dll was giving me problems.  So when I loaded this into dependency walker, it went out and found other dll's that were needed.
0
 
LVL 3

Author Comment

by:paix120
ID: 10738277
hmmm... I can't figure out which dll is causing the problem.
Anyone know which dll is involved with ADO connection or with Word.Application? And how do I find out what the problem is when the error is so vague?
0
 
LVL 3

Author Comment

by:paix120
ID: 10749304
just as a test, i tried excel.application and got the same exact error... does it have something to do with MSO9.dll - the microsoft object library?
0
 
LVL 3

Author Comment

by:paix120
ID: 10749308
when i run dependencies on the .exe, MSO9 doesn't come up...
0
 
LVL 3

Author Comment

by:paix120
ID: 10750592
ok, i tried running:
regsvr32 "c:\program files\microsoft office\office\mso9.dll"

and got the error:
"C:\.....\mso9.dll was loaded, but the DLLRegisterServer entry point was not found. This file can not be registered."

What does that mean??
0
 
LVL 3

Author Comment

by:paix120
ID: 10751251
OK my friend solved the problem. It seems to only be a problem with XP Pro, not Win 2000.

You have to do late binding instead of early binding, i.e. dim it as "object" instead of "excel.application". However, I still had to reference the excel9.olb as well.

Hopefully that will help anyone that comes across this post. Nothing else I found online seemed to work!

Thanks for your help,
Renee
0
 
LVL 3

Author Comment

by:paix120
ID: 10751256
My friend says that the late binding does have its disadvantages - it may take up more memory, and also since it doesn't know what object you're talking about, it doesn't help you as much during development. But at least it solved the dll error I was getting!
0
 

Expert Comment

by:skahlNNI
ID: 11143687
I had a similar problem with Outlook 2000 in Windows 2000, and calling the variable an object rather than outlook.application worked.

Thanks for posting your solution - it looks like it'd work for any of the Office 2000 programs and not just Excel.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question