VB6 - Word 2002 
Author Message
 VB6 - Word 2002

I'm running VB6 on an XP machine with Office XP.

When I run code to create a word application and then add
a document I get various problems in word.

If I step through the code then everything is fine, but
if I run the whole code or the compiled EXE the methods
fail.

The code is as simple as:-

Sub form_load()

    Set oApp = CreateObject("word.application")

    oApp.Visible = True

    oApp.documents.Add

End Sub

Is anyone having this problem or try the above out and
see if it's just my machine...

Thanks

Damian ;-)



Sat, 07 Aug 2004 21:21:14 GMT  
 VB6 - Word 2002
Hi.

I've tried your sample (from IDE and from compiled EXE) in
Windows 2000 Advanced Server and Windows XP Professional,
both with Office XP Professional SP1.

I found no problems or differences between the 4 scenarios.

Hope this helps,

   Adrian

This posting is provided "AS IS" with no warranties, and
confers no rights.

Quote:
>-----Original Message-----
>I'm running VB6 on an XP machine with Office XP.

>When I run code to create a word application and then add
>a document I get various problems in word.

>If I step through the code then everything is fine, but
>if I run the whole code or the compiled EXE the methods
>fail.

>The code is as simple as:-

>Sub form_load()

>    Set oApp = CreateObject("word.application")

>    oApp.Visible = True

>    oApp.documents.Add

>End Sub

>Is anyone having this problem or try the above out and
>see if it's just my machine...

>Thanks

>Damian ;-)

>.



Sat, 07 Aug 2004 23:35:20 GMT  
 VB6 - Word 2002
There's nothing wrong with this code. Do you have any Auto macros in Word
that might be interfering with your VB app?


Quote:
> I'm running VB6 on an XP machine with Office XP.

> When I run code to create a word application and then add
> a document I get various problems in word.

> If I step through the code then everything is fine, but
> if I run the whole code or the compiled EXE the methods
> fail.

> The code is as simple as:-

> Sub form_load()

>     Set oApp = CreateObject("word.application")

>     oApp.Visible = True

>     oApp.documents.Add

> End Sub

> Is anyone having this problem or try the above out and
> see if it's just my machine...

> Thanks

> Damian ;-)



Sun, 08 Aug 2004 05:04:51 GMT  
 VB6 - Word 2002
Hi

I see following problems:
1. Did you declare oApp as object? With the right scope?
2. Because you use "late binding", you don't see errors while stepping
through the code (only the interpreter is used, not the compiler). When you
run your program or compile it, the late binding is executed (=the reference
to your object is executed while runtime).
3. If you have installed more than one version of MS Word, the ProgID
"word.application" could be wrong. Open the Windows Registry an search for
"word.application". Maybee the correct ID is "word.application.10" or so (a
dot and the version number of Word).

Good luck.

Philipp

Damian Crawford schrieb in Nachricht

Quote:
>I'm running VB6 on an XP machine with Office XP.

>When I run code to create a word application and then add
>a document I get various problems in word.

>If I step through the code then everything is fine, but
>if I run the whole code or the compiled EXE the methods
>fail.

>The code is as simple as:-

>Sub form_load()

>    Set oApp = CreateObject("word.application")

>    oApp.Visible = True

>    oApp.documents.Add

>End Sub

>Is anyone having this problem or try the above out and
>see if it's just my machine...

>Thanks

>Damian ;-)



Sun, 08 Aug 2004 05:47:16 GMT  
 VB6 - Word 2002
I was using the createobject method to make the code
generic, but even if I reference the Microsoft Word 10.0
object and run the code, problems occur.

I'm using XP Home Edition and haven't yet installed SP1
of office, this is my next task/

The following code fails on the Add method, even if I use
the Open method and explicitly name a file the errors
occur. It's as if the code is running faster than the
windows events...??? I'm running on a 1.8GHz 256Mb
RAMBUS, but that shouldn't cause a problem.

I'll see what occurs after SP1.

Code:

Option Explicit

Private Sub form_load()

Dim oApp As Word.Application

'Start a new document in Word.
Set oApp = New Word.Application

'Add a new document
oApp.Documents.Add

'Make word visible
oApp.Visible = True

End Sub



Sun, 08 Aug 2004 06:10:34 GMT  
 VB6 - Word 2002
I was using the createobject method to make the code
generic, but even if I reference the Microsoft Word 10.0
object and run the code, problems occur.

I'm using XP Home Edition and haven't yet installed SP1
of office, this is my next task/

The following code fails on the Add method, even if I use
the Open method and explicitly name a file the errors
occur. It's as if the code is running faster than the
windows events...??? I'm running on a 1.8GHz 256Mb
RAMBUS, but that shouldn't cause a problem.

I'll see what occurs after SP1.

Code:

Option Explicit

Private Sub form_load()

Dim oApp As Word.Application

'Start a new document in Word.
Set oApp = New Word.Application

'Add a new document
oApp.Documents.Add

'Make word visible
oApp.Visible = True

End Sub



Sun, 08 Aug 2004 06:09:45 GMT  
 VB6 - Word 2002
The code looks correct. Can you tell more about the error (Description,
Number ...)?

Philipp

Damian Crawford schrieb in Nachricht

Quote:
>I was using the createobject method to make the code
>generic, but even if I reference the Microsoft Word 10.0
>object and run the code, problems occur.

>I'm using XP Home Edition and haven't yet installed SP1
>of office, this is my next task/

>The following code fails on the Add method, even if I use
>the Open method and explicitly name a file the errors
>occur. It's as if the code is running faster than the
>windows events...??? I'm running on a 1.8GHz 256Mb
>RAMBUS, but that shouldn't cause a problem.

>I'll see what occurs after SP1.

>Code:

>Option Explicit

>Private Sub form_load()

>Dim oApp As Word.Application

>'Start a new document in Word.
>Set oApp = New Word.Application

>'Add a new document
>oApp.Documents.Add

>'Make word visible
>oApp.Visible = True

>End Sub



Sun, 08 Aug 2004 06:57:58 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Word 2002: How to save a file in Word 97 format in Word 2002

2. VB6 Automation of Word 2002 fails after applying SP-2 update

3. Access 2002 Word 2002 Automation

4. MailEnvelope property in Excel 2002 and Word 2002

5. spped problems with MS Access 2002 as client, Word 2002 as server

6. Word 2002 Access 2002 Automation

7. Question for Microsoft about Word 2000 and Word 2002

8. Word 2002 Template won't open in Word 2000

9. Differences on word 2002 and word 2000 vba

10. Passing Userforms to subs (Word 2000 and 2002, I did not try Word 97)

11. Going from Word 97 to Word 2002 (Macros)

12. Word 200 and Word 2002: VBA6 compiler constant does not do the job

 

 
Powered by phpBB® Forum Software