Tip

Shows All Views in Excel Dynamically

Create an excel module and create 2 list boxs. Name it as mentioned in the script. Copy and paste this script to the module. It will go through all the database in your server (u can change to local or other server).

It will list out all the views available in the database. Select any view and it will shows all the records with the title :). This is a shortcut for users rather than have to buy another product to do reporting like seagate or brio.

p/s i just copy and paste the code below, it seems scattered, rearrange it to make it work again. Another thing create a button to run "PopulateDB" sub first. Contact me if u have any enquiries :)

Code:
Sub Report()
  Dim session As Object
  Dim r As Integer
  Dim db As Object
  Dim view As Object
  Dim doc As Object

  Rview$ = Worksheets("Sheet1").DropDowns("Report
List").List(Worksheets("Sheet1").DropDowns("Report List").Value)
  Dbase$ = Worksheets("Sheet1").DropDowns("Db
List").List(Worksheets("Sheet1").DropDowns("Db List").Value)
  Set session = CreateObject("Notes.NotesSession")
  Set db = session.GETDATABASE("AMMBNOTES", Dbase$)
  Set view = db.getView(Rview$)

  Set doc = view.GETFIRSTDOCUMENT
  r = 1
  On Error GoTo ErrRoutine
  While Not doc Is Nothing
    VC = doc.COLUMNVALUES
    c = 1
    For Each d In VC
      Worksheets("Sheet1").Cells(r, c).Value = d

    c = c + 1
  Next

  vr = r + 1
  Set doc = view.GETNEXTDOCUMENT(doc)
  Wend

  Set doc = Nothing
  Set view = Nothing
  Set view = Nothing
  Set db = Nothing
  Set session = Nothing

  Exit Sub

ErrRoutine:
If Err = 1005 Then Resume Next Else MsgBox Err

End Sub

Sub PopulateView()
  Dim session As Object
  Dim r As Integer
  Dim db As Object

  Dbase$ = Worksheets("Sheet1").DropDowns("Db
List").List(Worksheets("Sheet1").DropDowns("Db List").Value)
  Worksheets("Sheet1").DropDowns("Report List").RemoveAllItems
  Set session = CreateObject("Notes.NotesSession")
  Set db = session.GETDATABASE("AMMBNOTES", Dbase$)
    dbVIEW = db.VIEWS
    r = 1
    For Each view In dbVIEW
    Worksheets("Sheet1").DropDowns("Report List").AddItem (view.Name)
    r = r + 1
    Next

Set dbVIEW = Nothing
Set db = Nothing
Set session = Nothing

End Sub

Sub PopulateDB()
  Dim session As Object
  Dim dbdir As Object
  Dim db As Object

  Worksheets("Sheet1").DropDowns("Db List").RemoveAllItems
  Set session = CreateObject("Notes.NotesSession")
  Set dbdir = session.getDbDirectory("AMMBNOTES")
  Set db = dbdir.getFirstDatabase(1247)

  While Not db Is Nothing
  Worksheets("Sheet1").DropDowns("Db List").AddItem (db.filepath)
  Set db = dbdir.getNextDatabase
  Wend

  Set dbdir = Nothing
  Set session = Nothing
End Sub

This was first published in December 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.