Solved

Powerbuilder and excel VBA.

Posted on 2004-04-02
7
1,123 Views
Last Modified: 2013-12-26
Hi,

From my powerbuilder 8.0 application, I have to open an excel file with some parameters and same parameters I want to use in excel VBA as commandline() for further process.

Kindly help

Thanks,

Nagendra
0
Comment
Question by:bssoftware
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 10740344
Be more specific as to what the paramters are supposed to do within excel.

I am not sure if I understand this correctly. I understand you would like to pass some parameteres to excel. But, what would the paramteres do within excel? Depends on what needs to be done, I am sure there is a way.

regards-
0
 
LVL 5

Accepted Solution

by:
berXpert earned 50 total points
ID: 10741301
Hi,

to open excel use Run() function, this way you can send parameters. Note than opening this way you wont be able to use it as an object, so your only interaction with excel will be your command line.

Try this to open XXX.XLS file in read only mode   /r  parameter :

Run('C:\Program Files\Microsoft Office\OFFICE11\excel.exe /r c:\xxx.xls')




Now in Excel to get Command Line you can try this function:



Option Explicit
'---API Declare---
Private Declare Function GetCommandLine Lib "KERNEL32" Alias "GetCommandLineA" () As String

'Purpose     :  Returns the command line
'Inputs      :  N/A
'Outputs     :  The command line used to initate Excel
'Author      :  Andrew Baker (www.vbusers.com)
'Date        :  25/11/2000 03:33
'Notes       :  To return meaningful command line information you must open the workbook
'               by shelling it as a parameter for Excel.exe, eg. using the following syntax:
'               "D:\Program Files\Microsoft Office\Office\EXCEL.EXE" /MyCommand "d:\command line.xls"
'               i.e. The path to Excel, then the command and finally the workbook.
'               Note the paths are encapsulated in double quotes.

'               NT USERS: YOU MUST OPEN EXCEL BY SHELLING IT USING THE SYNTAX GIVEN ABOVE.
'               IF A WORKBOOK IS OPENED BY DOUBLE CLICKING IT IN EXPLORER THIS API CALL WILL CAUSE A GPF.
'                
'Revisions   :

Function CommandLine() As String
    Static ssCmd As String
    If Len(ssCmd) = 0 Then
        ssCmd = GetCommandLine
    End If
    CommandLine = ssCmd
End Function

'Demonstration routine
'Place in the "ThisWorkbook" class
Private Sub Workbook_Open()
    Dim sCmd As String
    sCmd = CommandLine
    MsgBox "Command line: " & sCmd
End Sub




I hop this helps

BerX
0
 
LVL 8

Expert Comment

by:Vikas_Dixit
ID: 10743608
berXpert's solution is going to work well......

For the First part, You can also take a look at ShellExecuteEx function. For an example, go to :
http://www.experts-exchange.com/Programming/Programming_Languages/PowerBuilder/Q_20663647.html
For passing parameters, use the lpParameters member of the st_shellexecuteinfo structure.

Regards,
Vikas
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 10747853
You can do this also:

You can connect to excel and the pass the paramters into a excel and read the value from that cell internally if you need.

string ls_parm
oleobject lole_excel
lole_excel = create oleobject

ls_parm = 'Parm1 Parm2'

ll_result = lole_excel.ConnectToNewObject( "excel.application")
lole_excel.application.workbooks.add( )
lole_excel.activesheet.cells(1,1).value = ls_parm
lole_excel.application.visible = true
if isvalid(iole_object) then destroy iole_object

regards-
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question