Share via


Adding Labels, Separator Lines, and Hyperlinks (Visual Basic .NET Tutorial) [Office 2003 SDK Documentation]

Previous  Adding ActiveX Controls

The following steps show you how to add labels, separator lines, and hyperlinks to the SimpleSample smart document.

  1. You will add the label, separator line, and hyperlink to the example element, so you don't need any additional constants, and you don't need to increase the number of types in the cTYPES constant. However, you need to insert the following code.

    In the ControlCount property subroutine, add 3 to the control count number for the cEXAMPLE constant. Replace the existing code in the cEXAMPLE case with the following code, or change your code to match.

            Case cEXAMPLE
                ControlCount = 4
    

    In the ControlTypeFromID property subroutine, insert the following code.

            Case 202
                ControlTypeFromID = C_TYPE.C_TYPE_LABEL
            Case 203
                ControlTypeFromID = C_TYPE.C_TYPE_SEPARATOR
            Case 204
                ControlTypeFromID = C_TYPE.C_TYPE_LINK
    

    In the ControlCaptionFromID property subroutine, insert the following code.

            Case 202
                ControlCaptionFromID = _
                    "This is a label. Below you will find a " & _
                    "separator line and a hyperlink to the " & _
                    "Microsoft home page."
            Case 203
                ControlCaptionFromID = "This text doesn't show"
            Case 204
                ControlCaptionFromID = "Microsoft.com"
    
  2. Use the InvokeControl method to specify actions for the hyperlink. Create the following variable and insert the following code into the Select Case statement in the InvokeControl method subroutine.

    Note  You need to add a reference to the Microsoft Internet Controls API.

    Dim objNav As SHDocVw.InternetExplorer
    
    ... [code between]
    
            Case 204
                Set objNav = New SHDocVw.InternetExplorer
                objNav.Navigate "http://www.microsoft.com"
                objNav.Visible = True
    

    Note  You can adjust the size of a separator line or the appearance of text in a label by placing code in the PopulateOther method and by using the Props parameter to specify the ISmartDocProperties key and value pairs. This is demonstrated in Adding ActiveX Controls.

  3. Recompile your SimpleSample smart document dynamic-link library (DLL), and copy it to the deployment location that you specified earlier.

  4. Because the Microsoft Internet Controls API is a COM interface and no primary interop assembly exists, Microsoft Visual Studio creates an interop assembly for you. You need to do the following to make sure your updated SimpleSample smart document functions properly:

    1. Copy that assembly to the deployment location.

    2. Add the following to the XML expansion pack manifest file (ManagedManifest.xml) that you created earlier. Within the SD:solution element for the SimpleSampleVB7.clsActions solution action handler, directly under the closing element for the current SD:file element, paste the following text.

      <SD:file>
         <SD:type>other</SD:type>
         <SD:version>1.0</SD:version>
         <SD:filePath>INTEROP FILE NAME AND PATH GOES HERE</SD:filePath>
      </SD:file>
      
    3. Replace INTEROP FILE NAME AND PATH GOES HERE in the preceding text with the correct path where you are deploying the smart document and the interop assembly file name, for example, C:\SimpleSample\Interop.SHDocVw.dll.

  5. When you reopen your SimpleSample smart document, delete the SimpleSample XML expansion pack, and then re-add it to the document.

Next  Creating a Smart Document Using Microsoft Visual Basic .NET