+ Reply to Thread
Results 1 to 2 of 2

Thread: VSTO Create a New Class

  1. #1
    Registered User
    Join Date
    01-07-2004
    Posts
    33

    VSTO Create a New Class

    Hi all,

    Using Visual Studio Pro 2008
    Office Pro 2007

    I am working through some tutorials from VSTO For Mere Mortals

    I created a Class:

    Public Class Sentence
        Private TextValue As String
        Property Text() As String
            Get
                Return TextValue
            End Get
            Set(ByVal value As String)
                TextValue = value
            End Set
        End Property
    
    End Class

    And I tried to Insantiate it

    Private Sub ThisDocument_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
            Dim Sentence1 As New Sentence()
            Dim Sentence2 As New Sentence()
            Sentence1.Text = "This is my first sentence. "
            Sentence2.Text = "This is my second sentence. "
            Me.Paragraphs(1).Range.InsertAfter( _
                Sentence1.Text & Sentence2.Text)
        End Sub
    The word "Sentence" is underlined with a blue squiggly line
    The error message is Type 'Sentence' is not defined.

    What am I doing wrong?
    Thanks,
    Winston
    thanks
    -goss

  2. #2
    Registered User
    Join Date
    01-07-2004
    Posts
    33

    Re: VSTO Create a New Class

    Solved.
    I think I must have created a global class directly under "Solution" in Solution Explorer
    I started a new project, and this time created the class within the word document and then added the code to the startup handler

    Works great
    thanks
    -goss

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0