Error bij nieuw project

Status
Niet open voor verdere reacties.

weswillem

Gebruiker
Lid geworden
8 nov 2011
Berichten
310
Bij een test formpje
waarop een combobox en een button is geplaatst
krijg ik bij het runnen elke keer de foutmelding.
Wat ben ik vergeten te referen?

Code:
Reference to class 'ApplicationClass' is not allowed when its assembly is linked using No-PIA mode.

Code:
Imports Word = Microsoft.Office.Interop.Word
Imports Access = Microsoft.Office.Interop.Access
Imports Excel = Microsoft.Office.Interop.Excel
Imports System.Runtime.InteropServices
Public Class Form1
    Inherits System.Windows.Forms.Form
    Private Sub InitForm()
        ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
        Dim a As String() = {"Access", "Excel", "PowerPoint", "Word"}
        ComboBox1.Items.AddRange(a)
        ComboBox1.SelectedIndex = 0
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Select Case ComboBox1.SelectedItem
            Case "Access"
            Case "Excel"
            Case "PowerPoint"
            Case "Word"

                Dim oWord As Word.ApplicationClass

                'Start Word and open the document.
                oWord = CreateObject("Word.Application")
                oWord.Visible = True
                oWord.Documents.Open("C:\Users\Willem-laptop\Documents\Doc1.doc")

                'Run the macros.
                oWord.Run("DoKbTest")
                oWord.Run("DoKbTestWithParameter", "Hello from VB .NET Client")

                'Quit Word.
                oWord.Quit()
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oWord)
                oWord = Nothing
        End Select
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        InitForm()
    End Sub
End Class
 
Laatst bewerkt:
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan