Dim oappWD as Word.Application: User defined type not defined 
Author Message
 Dim oappWD as Word.Application: User defined type not defined

Hi,
I get the error message : User defined type not defined (I hope, that's the
correct translation to English) in "Dim oappWD As Word.Application" the
following code. Of course there is a "link" to Microsoft Word 9.0 Object
Library

(by the way, I get the same error message in VB 6,0 and VBA of Office 2000)

Any ideas?

Looking forward to your answer

Bernd

Option Explicit

Private Sub cmdWord_Click()

    Dim oappWD As Word.Application
    Dim Doc, Paragraph

    On Error Resume Next
    Set oappWD = GetObject(, "Word.Application")
    If Err Then
        oappWD = CreateObject("Word.Application")
        oappWD.Activate
        oappWD.Visible = True
      Else
        oappWD.Visible = True
       End If

    On Error GoTo 0
    If oappWD.Options.VirusProtection = False Then
        oappWD.Options.VirusProtection = True
    End If

    'new
    Set Doc = oappWD.Documents.Add()
    Set Paragraph = Doc.paragraphs.Add()
    Paragraph.Range.Text = "Hallo Welt!"
    Paragraph.Range.Bold = True
    Paragraph.Range.Borders.Shadow = True

    'save
    oappWD.ActiveDocument.SaveAs "Hallo_Welt.Doc"

    'save all
    For Each Doc In oappWD.Documents
        Doc.Save
    Next

    'finish
    oappWD.Quit
    Set oappWD = Nothing
    Set Doc = Nothing
    Set Paragraph = Nothing

End Sub



Fri, 11 Jul 2003 04:45:35 GMT  
 Dim oappWD as Word.Application: User defined type not defined
this software seems to work fine:

Private Sub Befehl3_Click()
On Error GoTo Err_Befehl3_Click

    Dim oApp As Object
    Dim Doc, Paragraph

    Set oApp = CreateObject("Word.Application")
    oApp.Visible = True

      If Err Then
        oApp = CreateObject("Word.Application")
        oApp.Activate
        oApp.Visible = True
      Else
        oApp.Visible = True
       End If

    On Error GoTo 0
    If oApp.Options.VirusProtection = False Then
        oApp.Options.VirusProtection = True
    End If

    '?ffnen
    Set Doc = oApp.Documents.Open("c:\test.doc")

    'und ein weiteres Dokument
    Set Doc = oApp.Documents.Add()
    Set Paragraph = Doc.paragraphs.Add()
    Paragraph.Range.Text = "Hallo Welt!"
    Paragraph.Range.Bold = True
    Paragraph.Range.Borders.Shadow = True

    'save
     oApp.ActiveDocument.SaveAs "Hallo_Welt.Doc"

    'save all
    For Each Doc In oApp.Documents
        Doc.Save
    Next

    'finish
    'oApp.Quit
    Set oApp = Nothing
    Set Doc = Nothing
    Set Paragraph = Nothing

Exit_Befehl3_Click:
    Exit Sub

Err_Befehl3_Click:
    MsgBox Err.Description
    Resume Exit_Befehl3_Click

End Sub



Quote:
> Hi,
> I get the error message : User defined type not defined (I hope, that's
the
> correct translation to English) in "Dim oappWD As Word.Application" the
> following code. Of course there is a "link" to Microsoft Word 9.0 Object
> Library

> (by the way, I get the same error message in VB 6,0 and VBA of Office
2000)

> Any ideas?

> Looking forward to your answer

> Bernd

> Option Explicit

> Private Sub cmdWord_Click()

>     Dim oappWD As Word.Application
>     Dim Doc, Paragraph

>     On Error Resume Next
>     Set oappWD = GetObject(, "Word.Application")
>     If Err Then
>         oappWD = CreateObject("Word.Application")
>         oappWD.Activate
>         oappWD.Visible = True
>       Else
>         oappWD.Visible = True
>        End If

>     On Error GoTo 0
>     If oappWD.Options.VirusProtection = False Then
>         oappWD.Options.VirusProtection = True
>     End If

>     'new
>     Set Doc = oappWD.Documents.Add()
>     Set Paragraph = Doc.paragraphs.Add()
>     Paragraph.Range.Text = "Hallo Welt!"
>     Paragraph.Range.Bold = True
>     Paragraph.Range.Borders.Shadow = True

>     'save
>     oappWD.ActiveDocument.SaveAs "Hallo_Welt.Doc"

>     'save all
>     For Each Doc In oappWD.Documents
>         Doc.Save
>     Next

>     'finish
>     oappWD.Quit
>     Set oappWD = Nothing
>     Set Doc = Nothing
>     Set Paragraph = Nothing

> End Sub



Sat, 12 Jul 2003 06:02:03 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Dim oappWD as Word.Application: User defined type not defined

2. Help: user defined type not defined (Outlook.Application)

3. Help!!-NEWBIE - Application Wizard -(WROX BOOK) Error- User defined type not defined

4. Help!!-NEWBIE - Application Wizard -(WROX BOOK) Error- User defined type not defined

5. User Control - User-defined type not defined

6. User Defined Type Not Defined

7. Compile Error: User-defined type not defined

8. User-defined type not defined (Access 97)

9. Excel : User-defined type not define

10. Compile Error - User defined type not defined

11. User-defined type not defined (Access 2000)

12. User- Defined type not defined

 

 
Powered by phpBB® Forum Software