ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using Excel Library (https://www.excelbanter.com/excel-programming/335029-using-excel-library.html)

DP

Using Excel Library
 
Hi everyone:

I am tring to develop a product in MS Access. I have a query that uses VBA
programing to open an excel sheet and export data to it.

It works fine, except I would like to do some formatting like underlines and
bold and unfortunately I am getting application defined errors.

xlc.TextEffect.FontBold = True

I have not included the Excel 11 library in the reference, I am sure there
is where the goodies are, however, I am affaid if the user has a lower
version of Office what will occur, will it throw an error.

I have just called my objects in VBA like this to make it simple

Set xlx = CreateObject("Excel.Application")

Does anybody have any experience with this?

Thanks






Rob Bovey

Using Excel Library
 
"dp" wrote in message
...
It works fine, except I would like to do some formatting like underlines
and
bold and unfortunately I am getting application defined errors.

xlc.TextEffect.FontBold = True


The reason this fails is because it's not a valid construct in the Excel
object model.

I have not included the Excel 11 library in the reference, I am sure there
is where the goodies are, however, I am affaid if the user has a lower
version of Office what will occur, will it throw an error.


You are correct about this. What you should do is develop your
application with a reference set to the Excel object library and all of your
variables declared with the correct Excel object types. That way you can
"see" what you are doing in the Excel object model. Once you're sure it all
works and you're ready to deploy it, remove the Excel reference and change
all the Excel-specific object variable declarations to "As Object".

Keep in mind there have been new features added to the object model in
each version of Excel, so things you can do in Excel 2003 will not always
work in earlier versions of Excel. Unfortunately, there aren't any good
resources to determine what is new and what isn't, so your best bet is to
find a machine with the earliest version of Excel you expect your
application to run on and test it there.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm




Bob Phillips[_7_]

Using Excel Library
 
There is an example of Rob' suggestion at
http://www.xldynamic.com/source/xld.EarlyLate.html. It refers to Outlook,
but the principle is the same.

--
HTH

Bob Phillips

"Rob Bovey" wrote in message
...
"dp" wrote in message
...
It works fine, except I would like to do some formatting like underlines
and
bold and unfortunately I am getting application defined errors.

xlc.TextEffect.FontBold = True


The reason this fails is because it's not a valid construct in the

Excel
object model.

I have not included the Excel 11 library in the reference, I am sure

there
is where the goodies are, however, I am affaid if the user has a lower
version of Office what will occur, will it throw an error.


You are correct about this. What you should do is develop your
application with a reference set to the Excel object library and all of

your
variables declared with the correct Excel object types. That way you can
"see" what you are doing in the Excel object model. Once you're sure it

all
works and you're ready to deploy it, remove the Excel reference and change
all the Excel-specific object variable declarations to "As Object".

Keep in mind there have been new features added to the object model in
each version of Excel, so things you can do in Excel 2003 will not always
work in earlier versions of Excel. Unfortunately, there aren't any good
resources to determine what is new and what isn't, so your best bet is to
find a machine with the earliest version of Excel you expect your
application to run on and test it there.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm






DP

Using Excel Library
 
Hi Rob:

Thanks for your response.

I did try your suggestion. Its really cool to see all those object and
functions.

I tried to do a border around a range

Dim rng As Excel.Range

rng.BorderAround 1, -4138

I got the values by using the intermediate window
changed the xlmedium to those values, etc
removed the xls library
changed dim rng as object


Thanks,
I dont have a lower version of excel to test it on now. Hmm


"Rob Bovey" wrote:

"dp" wrote in message
...
It works fine, except I would like to do some formatting like underlines
and
bold and unfortunately I am getting application defined errors.

xlc.TextEffect.FontBold = True


The reason this fails is because it's not a valid construct in the Excel
object model.

I have not included the Excel 11 library in the reference, I am sure there
is where the goodies are, however, I am affaid if the user has a lower
version of Office what will occur, will it throw an error.


You are correct about this. What you should do is develop your
application with a reference set to the Excel object library and all of your
variables declared with the correct Excel object types. That way you can
"see" what you are doing in the Excel object model. Once you're sure it all
works and you're ready to deploy it, remove the Excel reference and change
all the Excel-specific object variable declarations to "As Object".

Keep in mind there have been new features added to the object model in
each version of Excel, so things you can do in Excel 2003 will not always
work in earlier versions of Excel. Unfortunately, there aren't any good
resources to determine what is new and what isn't, so your best bet is to
find a machine with the earliest version of Excel you expect your
application to run on and test it there.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm






All times are GMT +1. The time now is 12:11 PM.

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