ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Use VBA to collect information from Excel cells to av word documen (https://www.excelbanter.com/excel-programming/344206-use-vba-collect-information-excel-cells-av-word-documen.html)

Øyvind

Use VBA to collect information from Excel cells to av word documen
 
I have reference Office 11.0 Object lib. as a default. To get all the Excel
objects i activate the Microsoft Excel 11.0 Object library.

Then i can brows it all, by then i create a VBA code then VBA can't use the
Excel Objects as :
Dim Text as string
Text=cstr(Workbooks("BookName.xls").Worksheets("Sh eetName").Cells(1,1))

I have tried a line i use in VB6

Dim XLS
Dim Text as string
set XLS = GetObject(, "Excel.Application")

XLS.Workbooks("BookName.xls").Worksheets("SheetNam e").Cells(1,1))

This gives med tha same as
Text =cstr(Exel.Workbooks("BookName.xls").Worksheets("S heetName").Cells(1,1))

I can brows the object model, but i can't use it.

Is there an other code that enebles the Excel object model in WORD.

Best regards





--
Øyvind

Tom Ogilvy

Use VBA to collect information from Excel cells to av word documen
 
GetObject and CreateObject are the ways to go.

IF it works in VB6, it should work in VBA

I assume you have opened BookName.xls and it has a sheet named SheetName

You may want to look at the Automation Help file

http://support.microsoft.com/default...b;en-us;260410
Microsoft Office 2000 automation Help file is available in the Download
Center

--
Regards,
Tom Ogilvy

"Øyvind" wrote in message
...
I have reference Office 11.0 Object lib. as a default. To get all the

Excel
objects i activate the Microsoft Excel 11.0 Object library.

Then i can brows it all, by then i create a VBA code then VBA can't use

the
Excel Objects as :
Dim Text as string
Text=cstr(Workbooks("BookName.xls").Worksheets("Sh eetName").Cells(1,1))

I have tried a line i use in VB6

Dim XLS
Dim Text as string
set XLS = GetObject(, "Excel.Application")

XLS.Workbooks("BookName.xls").Worksheets("SheetNam e").Cells(1,1))

This gives med tha same as
Text

=cstr(Exel.Workbooks("BookName.xls").Worksheets("S heetName").Cells(1,1))

I can brows the object model, but i can't use it.

Is there an other code that enebles the Excel object model in WORD.

Best regards





--
Øyvind




Øyvind

Use VBA to collect information from Excel cells to av word doc
 
I had activated the workbook with current sheet. I read the automation help
file.
Thank you Tom.
--
Øyvind


"Tom Ogilvy" wrote:

GetObject and CreateObject are the ways to go.

IF it works in VB6, it should work in VBA

I assume you have opened BookName.xls and it has a sheet named SheetName

You may want to look at the Automation Help file

http://support.microsoft.com/default...b;en-us;260410
Microsoft Office 2000 automation Help file is available in the Download
Center

--
Regards,
Tom Ogilvy

"Øyvind" wrote in message
...
I have reference Office 11.0 Object lib. as a default. To get all the

Excel
objects i activate the Microsoft Excel 11.0 Object library.

Then i can brows it all, by then i create a VBA code then VBA can't use

the
Excel Objects as :
Dim Text as string
Text=cstr(Workbooks("BookName.xls").Worksheets("Sh eetName").Cells(1,1))

I have tried a line i use in VB6

Dim XLS
Dim Text as string
set XLS = GetObject(, "Excel.Application")

XLS.Workbooks("BookName.xls").Worksheets("SheetNam e").Cells(1,1))

This gives med tha same as
Text

=cstr(Exel.Workbooks("BookName.xls").Worksheets("S heetName").Cells(1,1))

I can brows the object model, but i can't use it.

Is there an other code that enebles the Excel object model in WORD.

Best regards





--
Øyvind






All times are GMT +1. The time now is 03:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com