understanding "imports" for vsto / excel
understanding "imports" for vsto / excel
understanding "imports" for vsto / excel
understanding "imports" for vsto / excel
understanding "imports" for vsto / excel
understanding "imports" for vsto / excel understanding "imports" for vsto / excel understanding "imports" for vsto / excel understanding "imports" for vsto / excel understanding "imports" for vsto / excel understanding "imports" for vsto / excel understanding "imports" for vsto / excel understanding "imports" for vsto / excel
understanding "imports" for vsto / excel understanding "imports" for vsto / excel
understanding "imports" for vsto / excel
Go Back  Xtreme Visual Basic Talk > > > understanding "imports" for vsto / excel


Reply
 
Thread Tools Display Modes
  #1  
Old 07-19-2011, 06:21 AM
simon271 simon271 is offline
Freshman
 
Join Date: Sep 2007
Location: Sunshine Coast
Posts: 28
Default understanding "imports" for vsto / excel


hello,

can someone briefly explain the use of "imports" at the top of each module. i am stumbling through development of an excel app in vsto and learning as i go.

in - my project - references i have added references and imported namespaces of everything that looks relevant to excel and office.

am i then to add "imports" to the top of each module where relevant.

eg my ribbon module

Code:
Imports Microsoft.Office.Tools.Ribbon

Public Class ribAtlas

    Private Sub ribAtlas_Load(ByVal sender As System.Object, ByVal e As RibbonUIEventArgs) Handles MyBase.Load

    End Sub

    Private Sub btnShowFrm_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles btnShowFrm.Click
        Dim form As New frmAddDetails
        form.Show()

    End Sub
End Class

and my form code that will (hopefully) paste info into excel

Code:
Imports Microsoft.Office.Interop.Excel

Public Class frmAddDetails

    Private Sub frmAddDetails_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        lboExpense.Visible = False
        lboIncome.Visible = True

    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        Dim strMonth As String
        strMonth = Format(DateTimePicker1.Value, "MMM")

        'go to the workbook as per the date selected
        Globals.ThisWorkbook.Worksheets(strMonth).activate()
        Globals.ThisWorkbook.ActiveSheet.range("a1").select()


        Dim direction As xldirection

        'get the next row
        Dim intNextRow As Integer
        direction = XlDirection.xlDown
        intNextRow = Globals.ThisWorkbook.ActiveSheet.range("a1").end(direction).row


        MsgBox(intNextRow)

        Me.Hide()
        Me.Dispose()

    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Hide()
        Me.Dispose()

    End Sub

End Class
before i added the imports microsoft.office.interop.excel i had no access to xldirection method.

what other import namespaces(????) are needed and in what modules?

i have a couple of books that i am referring to, but none seem to start at the beginning and explain what this imports does / is for.

thanks for all who give me some of their time to help.

simon.
Reply With Quote
  #2  
Old 07-19-2011, 07:16 AM
DrPunk's Avatar
DrPunkunderstanding "imports" for vsto / excel DrPunk is offline
Senior Contributor

* Expert *
 
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,403
Default

Imports just stops you having to type the location of the resource you're referring to.

So...
Code:
dim direction as microsoft.office.interop.excel.xldirection
direction = microsoft.office.interop.excel.xldirection.down
Becomes a lot easier to type using imports
Code:
Imports microsoft.office.interop.excel

dim direction as xldirection
direction = xldirection.down
But they achieve exactly the same thing.
__________________
There are no computers in heaven!
Reply With Quote
  #3  
Old 07-28-2011, 09:14 PM
simon271 simon271 is offline
Freshman
 
Join Date: Sep 2007
Location: Sunshine Coast
Posts: 28
Default

drpunk,
thanks for the info. most appreciated.
s
Reply With Quote
Reply

Tags
excel 2010 automation, imports, vsto


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
understanding "imports" for vsto / excel
understanding "imports" for vsto / excel
understanding "imports" for vsto / excel understanding "imports" for vsto / excel
understanding "imports" for vsto / excel
understanding "imports" for vsto / excel
understanding "imports" for vsto / excel understanding "imports" for vsto / excel understanding "imports" for vsto / excel understanding "imports" for vsto / excel understanding "imports" for vsto / excel understanding "imports" for vsto / excel understanding "imports" for vsto / excel
understanding "imports" for vsto / excel
understanding "imports" for vsto / excel
 
understanding "imports" for vsto / excel
understanding "imports" for vsto / excel
 
-->