Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Ghislain Marcotte
 
Posts: n/a
Default WorksheetFunction with VBA

Hello,

I'm trying to use Excel 2000 functions in a Word 2000 macro. My
version of Office is the French one.

For example, the following code does work:

Dim excelApp As Excel.Application
Set excelApp = CreateObject("Excel.Application")
Set table_ac = excelApp.Workbooks.Open ("c:\myfile.xls")
MsgBox table_ac.WorksheetFunction.sheets("Feuil1").cells( 10,5)

Now the problem is that other (all?) other WorksheetFunction's do work
in an Excel macro, but not in a Word macro, either in their English of
French VBA versions.

For example, ROUND works in an Excel Macro, yet it is not listed in
the available WorksheetFunctions of Excel VBA. (The function which is
listed is its French equivalent, ARRONDI).

So,
Application.WorksheetFunction.Round(5.96,1) works in an Excel macro,

but neither
table_ac.WorksheetFunction.Round(5.96,1) nor
table_ac.WorksheetFunction.Arrondi(5.96,1)
work in a Word macro!

Same goes for VLOOKUP (RECHERCHEV in French), for instance.

Any idea would be very appreciated!

Thanks,
Ghislain.
  #2   Report Post  
Jim Cone
 
Posts: n/a
Default

Ghislain,

I have some suggestions, however, I have never tried to use
Excel Worksheet Functions in Word.

1. "WorksheetFunction" in not a property of the
Worksheet, it is a property of the Application object.

2. Therefore...
MsgBox table_ac.WorksheetFunction.sheets("Feuil1").cells( 10,5)
should be...
MsgBox table_ac.Sheets("Feuil1").cells(10,5).Value

3. In addition...
table_ac.WorksheetFunction.Round(5.96,1)
should be...
excelApp.WorksheetFunction.Round(5.96,1)

Finally, even if you make the suggested changes,
I don't know whether worksheet functions will work in Word?
Please let us know.

Regards,
Jim Cone
San Francisco, USA


"Ghislain Marcotte" wrote in message
om...
Hello,

I'm trying to use Excel 2000 functions in a Word 2000 macro. My
version of Office is the French one.
For example, the following code does work:
Dim excelApp As Excel.Application
Set excelApp = CreateObject("Excel.Application")
Set table_ac = excelApp.Workbooks.Open ("c:\myfile.xls")
MsgBox table_ac.WorksheetFunction.sheets("Feuil1").cells( 10,5)


Now the problem is that other (all?) other WorksheetFunction's do work
in an Excel macro, but not in a Word macro, either in their English of
French VBA versions.
For example, ROUND works in an Excel Macro, yet it is not listed in
the available WorksheetFunctions of Excel VBA. (The function which is
listed is its French equivalent, ARRONDI).
So,
Application.WorksheetFunction.Round(5.96,1) works in an Excel macro,
but neither
table_ac.WorksheetFunction.Round(5.96,1) nor
table_ac.WorksheetFunction.Arrondi(5.96,1)
work in a Word macro!
Same goes for VLOOKUP (RECHERCHEV in French), for instance.
Any idea would be very appreciated!
Thanks,
Ghislain.

  #3   Report Post  
Ghislain Marcotte
 
Posts: n/a
Default

Hi Jim,

Thanks A LOT for your answers, my Word macro now works perfectly! I
don't think I could have found my mistake without your help.

Regards,
Ghislain.

"Jim Cone" wrote in message ...
Ghislain,

I have some suggestions, however, I have never tried to use
Excel Worksheet Functions in Word.

1. "WorksheetFunction" in not a property of the
Worksheet, it is a property of the Application object.

2. Therefore...
MsgBox table_ac.WorksheetFunction.sheets("Feuil1").cells( 10,5)
should be...
MsgBox table_ac.Sheets("Feuil1").cells(10,5).Value

3. In addition...
table_ac.WorksheetFunction.Round(5.96,1)
should be...
excelApp.WorksheetFunction.Round(5.96,1)

Finally, even if you make the suggested changes,
I don't know whether worksheet functions will work in Word?
Please let us know.

Regards,
Jim Cone
San Francisco, USA


"Ghislain Marcotte" wrote in message
om...
Hello,

I'm trying to use Excel 2000 functions in a Word 2000 macro. My
version of Office is the French one.
For example, the following code does work:
Dim excelApp As Excel.Application
Set excelApp = CreateObject("Excel.Application")
Set table_ac = excelApp.Workbooks.Open ("c:\myfile.xls")
MsgBox table_ac.WorksheetFunction.sheets("Feuil1").cells( 10,5)


Now the problem is that other (all?) other WorksheetFunction's do work
in an Excel macro, but not in a Word macro, either in their English of
French VBA versions.
For example, ROUND works in an Excel Macro, yet it is not listed in
the available WorksheetFunctions of Excel VBA. (The function which is
listed is its French equivalent, ARRONDI).
So,
Application.WorksheetFunction.Round(5.96,1) works in an Excel macro,
but neither
table_ac.WorksheetFunction.Round(5.96,1) nor
table_ac.WorksheetFunction.Arrondi(5.96,1)
work in a Word macro!
Same goes for VLOOKUP (RECHERCHEV in French), for instance.
Any idea would be very appreciated!
Thanks,
Ghislain.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Unable to get the NormSInv property of the WorksheetFunction clas David Roodman Excel Worksheet Functions 1 December 15th 04 12:15 PM


All times are GMT +1. The time now is 08:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"