Important alert: (current site time 10/24/2014 4:56:06 PM EDT)
 

VB icon

Llamar Funciones de excel a VB - Call Excel Functions on VB

Email
Submitted on: 1/31/2003 4:53:53 PM
By: Adrian G. 
Level: Beginner
User Rating: Unrated
Compatibility: VB 6.0
Views: 6810
author picture
(About the author)
 
     Llamar una funcion de MS-Excel en Visual Basic. Espero les sirva y si hay alguna observacion se los agradeceria mucho.
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :Llamar Funciones de excel a VB -Call Excel Functions on VB
'**************************************
' Para este ejempo use una standard exe
' Un CommandButton
' Una Label
' Un Text para que el usuario ingrese el parametro que es la base para el calculo de esta funcion.
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: Llamar Funciones de excel a VB -Call Excel Functions on VB
' Description:Llamar una funcion de MS-Excel en Visual Basic.
Espero les sirva y si hay alguna observacion se los agradeceria mucho.
' By: Adrian G.
'
' Inputs:Enviar los parametros que se ingresan en normalmente en Excel
'
' Returns:El valor que recibirias en cualquier celda de Excel.
'
' Assumes:Se necesitaba hacer la llamada a la funcion YearFrac() desde Excel para hacer ciertos calculos en VB y estos fueran almacenados luego en una Tabla de una BD en MS-Access.
Estube buscando informacion relacionada en varios lados de internet y por vario tiempo, pero no encontre nada, hasta que me tope con una pagina que me oriento a buscar sobre la libreria "MSOWCFLib" que es la que contiene las funciones de Excel.
1. Bueno solo necesitas hacer una referencia a esta libreria,
2. Crear el objeto,
3. hacer la llamada a la funcion y almacenar el valor o desplegarlo y
4. Cerrar el objeto sino te ira a servir.
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=42851&lngWId=1'for details.'**************************************

Private Sub Command1_Click()
'Hacer referencia a la libreria
'Microsoft Office Web Components Functions - MSOWCF.DLL (office 10 - [Office XP])
'Definir variable con Objecto oCATP
Dim oCATP As MSOWCFLib.oCATP
'Crear el Objeto
Set oCATP = New MSOWCFLib.oCATP
'Hacer la asignacion y la llamada a la funcion
Label1.Caption = oCATP.YEARFRAC(#4/15/1975#, #12/31/2001#, Text1.Text)
Set oCATP = Nothing
End Sub


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

4/14/2003 8:21:38 AM

Excelente rutinilla. Breve, concisa y buena. Con ella empiezo a averiguar algunas cosas mas.

(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.