VBA

Moderators: PavlinII
Number of threads: 1673
Number of posts: 3078

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
export data from discoverer to excel using vba Posted by shodan1 on 17 Aug 2005 at 3:24 AM
Hi experts out there,

I would like to export data from an external database query into excel. I have been reading through different forums and posts, but I stll don't really understand things. Here is my problem:
I have an external database query program called discoverer. It uses SQL statements to query an oracle database. However I do not know anything about SQL I can use this program because it is like a user friendly interface for non programmers.
What I have so far in excel vba is the following:

Set DiscoApp = CreateObject("Discoverer.Application")
DiscoApp.Visible = True
DiscoApp.Connect ("USERNAME/password@database")
Set Workbook = DiscoApp.documents.Open("X:\cre\dep\DTADISCO\ITEM & ITEM COST REPORTS\JME_itemcost_testv1.DIS")
Set Sheet = Workbook.Sheets("Crosstab_IC")


This code perfectly starts the external application called discoverer, runs the query and returns the data. BUT of course this data is still in the external application. How can I now get the data from this query directly imported in excel? Discoverer even has a button to import data in excel so the program must know the command somehow. Why is it than so complicated? I appreciate all help I can get. Please be easy on me, I'm just a beginner and experimenting with VBA

Report
Re: export data from discoverer to excel using vba Posted by PavlinII on 26 Sept 2005 at 11:41 AM
: Hi experts out there,
:
: I would like to export data from an external database query into excel. I have been reading through different forums and posts, but I stll don't really understand things. Here is my problem:
: I have an external database query program called discoverer. It uses SQL statements to query an oracle database. However I do not know anything about SQL I can use this program because it is like a user friendly interface for non programmers.
: What I have so far in excel vba is the following:
:
: Set DiscoApp = CreateObject("Discoverer.Application")
: DiscoApp.Visible = True
: DiscoApp.Connect ("USERNAME/password@database")
: Set Workbook = DiscoApp.documents.Open("X:\cre\dep\DTADISCO\ITEM & ITEM COST REPORTS\JME_itemcost_testv1.DIS")
: Set dSheet = Workbook.Sheets("Crosstab_IC")
:
:
: This code perfectly starts the external application called discoverer, runs the query and returns the data. BUT of course this data is still in the external application. How can I now get the data from this query directly imported in excel? Discoverer even has a button to import data in excel so the program must know the command somehow. Why is it than so complicated? I appreciate all help I can get. Please be easy on me, I'm just a beginner and experimenting with VBA
:
:
..:: oh, NO! I've just closed this window and lost my answer, so let's say I have good mood and I'm not lazy to write it again :) ::..

Hi,
let's take a look at it.. I don't know Discoverer but it's object model looks very similar to Excel's one. So your task could be solvable.. Ideal situation would be when discoverer is using Excel's object, but the world would be too much ping :) Let's say your discoverer sheet is called dSheet.
Dim eWB As Excel.Workbook
  Set eWB = Excel.Workbooks.Add()
  eWB.Worksheets.Add(dSheet)
  eWB.SaveAs(..)
  ..
  eWB.Close(True)
But I guess .Add(dSheet) will cause error because of incompatible object types.
But if the structure is really similar, there must exist dSheet.Range(..) or dSheet.Cells(.., ..) which provides you access to certain cells of result of your SQL query. Now, you can copy all the content manually
Dim eSheet As Excel.Worksheet, r As Integer, c As Integer
  Set eSheet=eWB.Worksheets(1)
  For r=1 To dSheet.Rows.Count
    For c=1 to dSheet.Columns.Count
      eSheet.Cells(r, c) = dSheet.Cells(r, c)
    Next c
  Next r
  eWB.Application.Visible=True
  ...
  eWB.Close(True)
I hope you don't have too large datasets because this would be quite slow process with great amount of data..
Hope this helps...

Pavlin II[/size]

Don't take life too seriously anyway you won't escape alive from it!


Report
Re: export data from discoverer to excel using vba Posted by marschmrk on 9 Aug 2011 at 2:58 AM
Hello!
It is my problem too. I would like opening a *.dis form the excel/vba.
Your code is opening the discoverer frame, but it doesnt make any other.

I am just a client, and i dont need any "USERNAME/password@database" for useing the discoverer.

I tried this, in the VBA:
Set DiscoApp = CreateObject("Discoverer.Application")
DiscoApp.Visible = True

Dim user As String
Dim pswd As String
Dim dtb As String
Dim connct As String

user = ""
pswd = ""
dtb = "teszt" 'gondolom ez már nem üres...

connct = user & "/" & pswd & "@" & dtb

DiscoApp.Connect (connct)

Set Workbook = DiscoApp.documents.Open("\ASZExx\...\teszt.DIS")
Set dSheet = Workbook.Sheets("Crosstab_IC")

It's opening the dis frame, and when the "SET Workbook..." part is active, then the connection window is jumping up.

Maybe I need some pasword for the VBA-DIS connection, or other err?
thanks
Report
This post has been deleted. Posted by marschmrk on 9 Aug 2011 at 3:02 AM
This post has been deleted.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.