Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Word, PowerPoint, Outlook, and Other Office Products > How to call an excell function from access?


Reply
 
Thread Tools Display Modes
  #1  
Old 08-14-2003, 12:48 PM
bob123 bob123 is offline
Centurion
 
Join Date: Jul 2003
Posts: 95
Default How to call an excell function from access?


Aaargh. A range error was driving me nuts so I decided to move my function to excell and just call it from access. Unfortuneately I don't know how to do this and it doesn't appear to be the same as calling a sub. Can someone help fix these lines of code?


Code:
strLate = mobjExcel.Application.Run "test2.xls!StringSplitter(Late)" strNoDate = mobjExcel.Application.Run "test2.xls!StringSplitter(NoDate)" strNada = mobjExcel.Application.Run "test2.xls!StringSplitter(Nada)"

See my previous thread if you need to see what the rest of the code is.
Reply With Quote
  #2  
Old 08-14-2003, 02:29 PM
Stefan1 Stefan1 is offline
Newcomer
 
Join Date: Jul 2003
Location: Mount Maunganui, NZ
Posts: 7
Default

Hi. I have run procedures in excel from access using the following code -

Code:
Set objXL = CreateObject("Excel.Application")
With objXL.Application
'    .Visible = True
    'Open the Workbook
    .Workbooks.Open strFilePath
    'Include CARMA in menu, run AutoOpen
    .ActiveWorkbook.RunAutoMacros xlAutoOpen
    .Run (strExcelProcedureName)
    .ActiveWorkbook.Save
    .ActiveWorkbook.Close
End With
objXL.Application.Quit
Set objXL = Nothing
instead of using the .Application.Run you just use .Run. Although I think you might be having a problem trying to pass a parameter through with your procedure name inside the string (something I was having a problem with a couple of days ago (but within Access)). I would try breaking it out i.e.

Code:
Set objXL = CreateObject("Excel.Application")
With objXL.Application
    .Run (strExcelProcedureName,strParam1,strParam2)
End With
objXL.Application.Quit
Set objXL = Nothing
Hope this helps
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Algorithm Problems Arkasizer Game Programming 5 12-18-2002 07:37 AM
Loading a Sprite Termor Game Programming 14 12-07-2002 07:37 AM
MS Winsocket gibson General 3 07-20-2001 10:03 AM
Saving as Random Access File VillageBaboon General 5 06-14-2001 10:25 PM
link function to textboxes golash General 2 05-03-2001 11:57 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->