Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default VBA to C# conversion.

For many of the tasks that I want to accomplish I am referrred to recording a
macro with in EXCEL and then looking at the results. What has become a major
obstactle is converting the VBA code to C#. For example I recorded a simple
macro for formatting a range of cells:

//Range("B1:D1").Select
//With Selection
// .HorizontalAlignment = xlCenterAcrossSelection
// .VerticalAlignment = xlBottom
// .WrapText = False
// .Orientation = 0
// .AddIndent = False
// .IndentLevel = 0
// .ShrinkToFit = False
// .ReadingOrder = xlContext
// .MergeCells = False
//End With

The problem with this code is that in C# there doesn't seem to be xlContext,
xlBottom, and xlCenterAcrosssSelection. There doesn't seem to be a Range
object that has a Select method. There isn't a 'Selection' object. The return
from Range.Select is an object which of course doesn't have all of the
properties listed in the VBA code 'WITH'. This is just a smple example I can
see more anomalies popping up with the VBA code gets more complicated.
Suggestions?

Thank you.

Kevin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default VBA to C# conversion.

Hi Kevin

For the enumerations (xlBottom el al), see/search the object browser in
excel's VB editor for their corresponding numerical values.

For the rest; if you are to remote control Excel then you must set reference
to it (and I can't tell how that's done with C#). Once referenced, you
should in theory have access to the objects.

HTH. Best wishes Harald

"Kevin Burton" wrote in message
...
For many of the tasks that I want to accomplish I am referrred to
recording a
macro with in EXCEL and then looking at the results. What has become a
major
obstactle is converting the VBA code to C#. For example I recorded a
simple
macro for formatting a range of cells:

//Range("B1:D1").Select
//With Selection
// .HorizontalAlignment = xlCenterAcrossSelection
// .VerticalAlignment = xlBottom
// .WrapText = False
// .Orientation = 0
// .AddIndent = False
// .IndentLevel = 0
// .ShrinkToFit = False
// .ReadingOrder = xlContext
// .MergeCells = False
//End With

The problem with this code is that in C# there doesn't seem to be
xlContext,
xlBottom, and xlCenterAcrosssSelection. There doesn't seem to be a Range
object that has a Select method. There isn't a 'Selection' object. The
return
from Range.Select is an object which of course doesn't have all of the
properties listed in the VBA code 'WITH'. This is just a smple example I
can
see more anomalies popping up with the VBA code gets more complicated.
Suggestions?

Thank you.

Kevin


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
conversion Bailey Excel Discussion (Misc queries) 1 August 12th 09 11:13 PM
Conversion to value between 1 to 10 only! wilchong via OfficeKB.com New Users to Excel 5 May 23rd 08 02:10 PM
Conversion Suleman[_2_] Excel Worksheet Functions 1 April 27th 08 08:51 PM
conversion help oldsquid Excel Discussion (Misc queries) 7 March 29th 08 10:01 PM
XLS to CSV conversion border21 Excel Programming 2 June 10th 04 02:38 AM


All times are GMT +1. The time now is 02:53 AM.

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

About Us

"It's about Microsoft Excel"