Solved

Powerbuilder and excel VBA.

Posted on 2004-04-02
7
1,099 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

752 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