| Home | Forums | Reviews | Articles | Register |
![]() |
| Thread Tools | Rate Thread |
|
|
|
| |
|
Lynn McGuire
Guest
Posts: n/a
|
On 1/17/2011 1:49 PM, Lucas Coppio wrote:
> Hi, ive done a small program using OLE automation but I still don't > know how to put borders on some cells > This is the MACRO code, but I need to translate it to something the VC+ > +/OLE2 can understand, but I have no clue on how to do that. > > Sub Macro1() > ' > ' Macro1 Macro > ' > > ' > Range("B10:I50").Select > Selection.Borders(xlDiagonalDown).LineStyle = xlNone > Selection.Borders(xlDiagonalUp).LineStyle = xlNone > With Selection.Borders(xlEdgeLeft) > .LineStyle = xlContinuous > .ColorIndex = 0 > .TintAndShade = 0 > .Weight = xlThin > End With > With Selection.Borders(xlEdgeTop) > .LineStyle = xlContinuous > .ColorIndex = 0 > .TintAndShade = 0 > .Weight = xlThin > End With > With Selection.Borders(xlEdgeBottom) > .LineStyle = xlContinuous > .ColorIndex = 0 > .TintAndShade = 0 > .Weight = xlThin > End With > With Selection.Borders(xlEdgeRight) > .LineStyle = xlContinuous > .ColorIndex = 0 > .TintAndShade = 0 > .Weight = xlThin > End With > With Selection.Borders(xlInsideVertical) > .LineStyle = xlContinuous > .ColorIndex = 0 > .TintAndShade = 0 > .Weight = xlThin > End With > With Selection.Borders(xlInsideHorizontal) > .LineStyle = xlContinuous > .ColorIndex = 0 > .TintAndShade = 0 > .Weight = xlThin > End With > End Sub Here is a full C++ OLE Automation interface for Excel: http://groups.google.com/group/micro...eb7ded92ab5d93 Lynn |
|
||
|
||||
|
Lucas Coppio
Guest
Posts: n/a
|
On 17 jan, 19:01, Lynn McGuire <l...@winsim.com> wrote:
> On 1/17/2011 1:49 PM, Lucas Coppio wrote: > > > > > Hi, ive done a small program using OLE automation but I still don't > > know how to put borders on some cells > > This is the MACRO code, but I need to translate it to something the VC+ > > +/OLE2 can understand, but I have *no clue on how to do that. > > > Sub Macro1() > > ' > > ' Macro1 Macro > > ' > > > ' > > * * *Range("B10:I50").Select > > * * *Selection.Borders(xlDiagonalDown).LineStyle = xlNone > > * * *Selection.Borders(xlDiagonalUp).LineStyle = xlNone > > * * *With Selection.Borders(xlEdgeLeft) > > * * * * *.LineStyle = xlContinuous > > * * * * *.ColorIndex = 0 > > * * * * *.TintAndShade = 0 > > * * * * *.Weight = xlThin > > * * *End With > > * * *With Selection.Borders(xlEdgeTop) > > * * * * *.LineStyle = xlContinuous > > * * * * *.ColorIndex = 0 > > * * * * *.TintAndShade = 0 > > * * * * *.Weight = xlThin > > * * *End With > > * * *With Selection.Borders(xlEdgeBottom) > > * * * * *.LineStyle = xlContinuous > > * * * * *.ColorIndex = 0 > > * * * * *.TintAndShade = 0 > > * * * * *.Weight = xlThin > > * * *End With > > * * *With Selection.Borders(xlEdgeRight) > > * * * * *.LineStyle = xlContinuous > > * * * * *.ColorIndex = 0 > > * * * * *.TintAndShade = 0 > > * * * * *.Weight = xlThin > > * * *End With > > * * *With Selection.Borders(xlInsideVertical) > > * * * * *.LineStyle = xlContinuous > > * * * * *.ColorIndex = 0 > > * * * * *.TintAndShade = 0 > > * * * * *.Weight = xlThin > > * * *End With > > * * *With Selection.Borders(xlInsideHorizontal) > > * * * * *.LineStyle = xlContinuous > > * * * * *.ColorIndex = 0 > > * * * * *.TintAndShade = 0 > > * * * * *.Weight = xlThin > > * * *End With > > End Sub > > Here is a full C++ OLE Automation interface for Excel: > > http://groups.google.com/group/micro...rowse_thread/t... > > Lynn Thank you Lynn, I'll give it a deep look later (i'm copying the codes right now to a new project and will try to compile a test program later). But unfortunatelly this is a little urgent and I don't have much able time to learn everything of such a complex code, I have a program that generates a datasheet in XLS using the OLE automation, but I have to add borders to a big table and it proves to be quite hard to me right now mainly because I'm not usued to do codes for computers (I'm a firmware developer for microcontrolers and embed devices). I'm basically using the example that is in msdn about OLE automation (automation without using MFC and #import), so its basically: HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, LPOLESTR ptName, int cArgs...) { .... } and things like this in the main() // Get ActiveSheet object IDispatch *pXlSheet; { VARIANT result; VariantInit(&result); AutoWrap(DISPATCH_PROPERTYGET, &result, pXlApp, L"ActiveSheet", 0); pXlSheet = result.pdispVal; } the program is working fine right now, except by the borders that I need in the ranges: Range("B10:I50").Select Range("B60:I100").Select Range("B110:I150").Select Range("B160:I200").Select in anyway, I will understand if you don't want to code it for me or to point where I may find it in the code you just showed me. |
|
||
|
||||
|
Lynn McGuire
Guest
Posts: n/a
|
On 1/18/2011 11:10 AM, Lucas Coppio wrote:
> On 17 jan, 19:01, Lynn McGuire<l...@winsim.com> wrote: >> On 1/17/2011 1:49 PM, Lucas Coppio wrote: >> >> >> >>> Hi, ive done a small program using OLE automation but I still don't >>> know how to put borders on some cells >>> This is the MACRO code, but I need to translate it to something the VC+ >>> +/OLE2 can understand, but I have no clue on how to do that. >> >>> Sub Macro1() >>> ' >>> ' Macro1 Macro >>> ' >> >>> ' >>> Range("B10:I50").Select >>> Selection.Borders(xlDiagonalDown).LineStyle = xlNone >>> Selection.Borders(xlDiagonalUp).LineStyle = xlNone >>> With Selection.Borders(xlEdgeLeft) >>> .LineStyle = xlContinuous >>> .ColorIndex = 0 >>> .TintAndShade = 0 >>> .Weight = xlThin >>> End With >>> With Selection.Borders(xlEdgeTop) >>> .LineStyle = xlContinuous >>> .ColorIndex = 0 >>> .TintAndShade = 0 >>> .Weight = xlThin >>> End With >>> With Selection.Borders(xlEdgeBottom) >>> .LineStyle = xlContinuous >>> .ColorIndex = 0 >>> .TintAndShade = 0 >>> .Weight = xlThin >>> End With >>> With Selection.Borders(xlEdgeRight) >>> .LineStyle = xlContinuous >>> .ColorIndex = 0 >>> .TintAndShade = 0 >>> .Weight = xlThin >>> End With >>> With Selection.Borders(xlInsideVertical) >>> .LineStyle = xlContinuous >>> .ColorIndex = 0 >>> .TintAndShade = 0 >>> .Weight = xlThin >>> End With >>> With Selection.Borders(xlInsideHorizontal) >>> .LineStyle = xlContinuous >>> .ColorIndex = 0 >>> .TintAndShade = 0 >>> .Weight = xlThin >>> End With >>> End Sub >> >> Here is a full C++ OLE Automation interface for Excel: >> >> http://groups.google.com/group/micro...rowse_thread/t... >> >> Lynn > > Thank you Lynn, I'll give it a deep look later (i'm copying the codes > right now to a new project and will try to compile a test program > later). > But unfortunatelly this is a little urgent and I don't have much able > time to learn everything of such a complex code, I have a program that > generates a datasheet in XLS using the OLE automation, but I have to > add borders to a big table and it proves to be quite hard to me right > now mainly because I'm not usued to do codes for computers (I'm a > firmware developer for microcontrolers and embed devices). > > I'm basically using the example that is in msdn about OLE automation > (automation without using MFC and #import), so its basically: > > HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, > LPOLESTR ptName, int cArgs...) { > ... > } > > and things like this in the main() > > // Get ActiveSheet object > IDispatch *pXlSheet; > { > VARIANT result; > VariantInit(&result); > AutoWrap(DISPATCH_PROPERTYGET,&result, pXlApp, L"ActiveSheet", > 0); > pXlSheet = result.pdispVal; > } > > the program is working fine right now, except by the borders that I > need in the ranges: > > Range("B10:I50").Select > Range("B60:I100").Select > Range("B110:I150").Select > Range("B160:I200").Select > > in anyway, I will understand if you don't want to code it for me or to > point where I may find it in the code you just showed me. That is the problem. There is a LOT of coding items that you have to handle in order to initialize the interface. This is basically the sequence of events: > // fm2n_old.cpp > // The OLE Automation interface to Excel is mostly written using: > // "How to automate Excel from C++ without using MFC or #import" > // http://support.microsoft.com/kb/216686 // to call this code : // if (ConnectToNotebook (notebook, RunInTestMode, true)) // { // // do your excel data transfer here // DisconnectFromNotebook (RunInTestMode); // } // see getCellInfo or putCellInfo for single cell data transfer examples // see PutRowInTable for bulk transfer example, note that the more data can // be transferred at one time, the faster the data transfer is For formatting a range, see the functions: int setRangeFont (std::string rangeValue, std::string fontNameValue, int boldValue, int sizeValue, int colorValue); int SetRangeWidthAlignment (std::string rangeValue, int columnWidthValue, int horizontalAlignmentValue); The C++ OLE automation interface for Excel (or any other OLE server) is very involved. Lynn |
|
||
|
||||
|
Lucas Coppio
Guest
Posts: n/a
|
On Jan 18, 4:18*pm, Lynn McGuire <l...@winsim.com> wrote:
> On 1/18/2011 11:10 AM, Lucas Coppio wrote: > > > > > On 17 jan, 19:01, Lynn McGuire<l...@winsim.com> *wrote: > >> On 1/17/2011 1:49 PM, Lucas Coppio wrote: > > >>> Hi, ive done a small program using OLE automation but I still don't > >>> know how to put borders on some cells > >>> This is the MACRO code, but I need to translate it to something the VC+ > >>> +/OLE2 can understand, but I have *no clue on how to do that. > > >>> Sub Macro1() > >>> ' > >>> ' Macro1 Macro > >>> ' > > >>> ' > >>> * * * Range("B10:I50").Select > >>> * * * Selection.Borders(xlDiagonalDown).LineStyle = xlNone > >>> * * * Selection.Borders(xlDiagonalUp).LineStyle = xlNone > >>> * * * With Selection.Borders(xlEdgeLeft) > >>> * * * * * .LineStyle = xlContinuous > >>> * * * * * .ColorIndex = 0 > >>> * * * * * .TintAndShade = 0 > >>> * * * * * .Weight = xlThin > >>> * * * End With > >>> * * * With Selection.Borders(xlEdgeTop) > >>> * * * * * .LineStyle = xlContinuous > >>> * * * * * .ColorIndex = 0 > >>> * * * * * .TintAndShade = 0 > >>> * * * * * .Weight = xlThin > >>> * * * End With > >>> * * * With Selection.Borders(xlEdgeBottom) > >>> * * * * * .LineStyle = xlContinuous > >>> * * * * * .ColorIndex = 0 > >>> * * * * * .TintAndShade = 0 > >>> * * * * * .Weight = xlThin > >>> * * * End With > >>> * * * With Selection.Borders(xlEdgeRight) > >>> * * * * * .LineStyle = xlContinuous > >>> * * * * * .ColorIndex = 0 > >>> * * * * * .TintAndShade = 0 > >>> * * * * * .Weight = xlThin > >>> * * * End With > >>> * * * With Selection.Borders(xlInsideVertical) > >>> * * * * * .LineStyle = xlContinuous > >>> * * * * * .ColorIndex = 0 > >>> * * * * * .TintAndShade = 0 > >>> * * * * * .Weight = xlThin > >>> * * * End With > >>> * * * With Selection.Borders(xlInsideHorizontal) > >>> * * * * * .LineStyle = xlContinuous > >>> * * * * * .ColorIndex = 0 > >>> * * * * * .TintAndShade = 0 > >>> * * * * * .Weight = xlThin > >>> * * * End With > >>> End Sub > > >> Here is a full C++ OLE Automation interface for Excel: > > >>http://groups.google.com/group/micro...rowse_thread/t.... > > >> Lynn > > > Thank you Lynn, I'll give it a deep look later (i'm copying the codes > > right now to a new project and will try to compile a test program > > later). > > But unfortunatelly this is a little urgent and I don't have much able > > time to learn everything of such a complex code, I have a program that > > generates a datasheet in XLS using the OLE automation, but I have to > > add borders to a big table and it proves to be quite hard to me right > > now mainly because I'm not usued to do codes for computers (I'm a > > firmware developer for microcontrolers and embed devices). > > > I'm basically using the example that is in msdn about OLE automation > > (automation without using MFC and #import), so its basically: > > > HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, > > LPOLESTR ptName, int cArgs...) { > > ... > > } > > > and things like this in the main() > > > * * // Get ActiveSheet object > > * * IDispatch *pXlSheet; > > * * { > > * * * *VARIANT result; > > * * * *VariantInit(&result); > > * * * *AutoWrap(DISPATCH_PROPERTYGET,&result, pXlApp, L"ActiveSheet", > > 0); > > * * * *pXlSheet = result.pdispVal; > > * * } > > > the program is working fine right now, except by the borders that I > > need in the ranges: > > > Range("B10:I50").Select > > Range("B60:I100").Select > > Range("B110:I150").Select > > Range("B160:I200").Select > > > in anyway, I will understand if you don't want to code it for me or to > > point where I may find it in the code you just showed me. > > That is the problem. *There is a LOT of coding items that you have > to handle in order to initialize the interface. *This is basically > the sequence of events: > > *> // fm2n_old.cpp > > *> // The OLE Automation interface to Excel is mostly written using: > *> // "How to automate Excel from C++ without using MFC or #import" > *> //http://support.microsoft.com/kb/216686 > > // *to call this code : > // * * * * * * *if (ConnectToNotebook (notebook, RunInTestMode, true)) > // * * * * * * *{ > // * * * * * * * * * * *// *do your excel data transfer here > // * * * * * * * * * * *DisconnectFromNotebook (RunInTestMode); > // * * * * * * *} > > // *see getCellInfo or putCellInfo for single cell data transfer examples > > // *see PutRowInTable for bulk transfer example, note that the more data can > // * * *be transferred at one time, the faster the data transfer is > > For formatting a range, see the functions: > * * int setRangeFont (std::string rangeValue, std::string fontNameValue, int boldValue, int sizeValue, int colorValue); > * * int SetRangeWidthAlignment (std::string rangeValue, int columnWidthValue, int horizontalAlignmentValue); > > The C++ OLE automation interface for Excel (or any other OLE server) > is very involved. > > Lynn I tried to make a simple main with the Connect to Notebook, but when I compile I receive those errors. Error 1 error C2065: 'MaxItemsInRow' : undeclared identifier e:\users \user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.h 32 Error 2 error C2065: 'MaxLineChunks' : undeclared identifier e:\users \user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.h 38 Error 4 error C2664: 'FindFirstFileW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR' e:\users\user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 137 Error 3 error C2664: 'GetModuleFileNameW' : cannot convert parameter 2 from 'char [4096]' to 'LPWCH' e:\users\user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 117 Error 7 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'char [2000]' to 'LPCWSTR' e:\users\user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 210 Error 8 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'char [2000]' to 'LPCWSTR' e:\users\user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 231 Error 9 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'char [2000]' to 'LPCWSTR' e:\users\user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 274 Error 5 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR' e:\users\user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 154 Error 6 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR' e:\users\user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 176 Error 12 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR' e:\users\user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 496 Error 10 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [25]' to 'LPCWSTR' e:\users\user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 305 Error 11 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [44]' to 'LPCWSTR' e:\users\user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 328 Error 13 error C3861: 'SetUnitsCase': identifier not found e:\users \user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 1851 Error 14 error C3861: 'SetUnitsCase': identifier not found e:\users \user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 1864 Error 15 error C3861: 'SetUnitsCase': identifier not found e:\users \user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 1879 |
|
||
|
||||
|
Lucas Coppio
Guest
Posts: n/a
|
On Jan 18, 4:18*pm, Lynn McGuire <l...@winsim.com> wrote:
> On 1/18/2011 11:10 AM, Lucas Coppio wrote: > > > > > On 17 jan, 19:01, Lynn McGuire<l...@winsim.com> *wrote: > >> On 1/17/2011 1:49 PM, Lucas Coppio wrote: > > >>> Hi, ive done a small program using OLE automation but I still don't > >>> know how to put borders on some cells > >>> This is the MACRO code, but I need to translate it to something the VC+ > >>> +/OLE2 can understand, but I have *no clue on how to do that. > > >>> Sub Macro1() > >>> ' > >>> ' Macro1 Macro > >>> ' > > >>> ' > >>> * * * Range("B10:I50").Select > >>> * * * Selection.Borders(xlDiagonalDown).LineStyle = xlNone > >>> * * * Selection.Borders(xlDiagonalUp).LineStyle = xlNone > >>> * * * With Selection.Borders(xlEdgeLeft) > >>> * * * * * .LineStyle = xlContinuous > >>> * * * * * .ColorIndex = 0 > >>> * * * * * .TintAndShade = 0 > >>> * * * * * .Weight = xlThin > >>> * * * End With > >>> * * * With Selection.Borders(xlEdgeTop) > >>> * * * * * .LineStyle = xlContinuous > >>> * * * * * .ColorIndex = 0 > >>> * * * * * .TintAndShade = 0 > >>> * * * * * .Weight = xlThin > >>> * * * End With > >>> * * * With Selection.Borders(xlEdgeBottom) > >>> * * * * * .LineStyle = xlContinuous > >>> * * * * * .ColorIndex = 0 > >>> * * * * * .TintAndShade = 0 > >>> * * * * * .Weight = xlThin > >>> * * * End With > >>> * * * With Selection.Borders(xlEdgeRight) > >>> * * * * * .LineStyle = xlContinuous > >>> * * * * * .ColorIndex = 0 > >>> * * * * * .TintAndShade = 0 > >>> * * * * * .Weight = xlThin > >>> * * * End With > >>> * * * With Selection.Borders(xlInsideVertical) > >>> * * * * * .LineStyle = xlContinuous > >>> * * * * * .ColorIndex = 0 > >>> * * * * * .TintAndShade = 0 > >>> * * * * * .Weight = xlThin > >>> * * * End With > >>> * * * With Selection.Borders(xlInsideHorizontal) > >>> * * * * * .LineStyle = xlContinuous > >>> * * * * * .ColorIndex = 0 > >>> * * * * * .TintAndShade = 0 > >>> * * * * * .Weight = xlThin > >>> * * * End With > >>> End Sub > > >> Here is a full C++ OLE Automation interface for Excel: > > >>http://groups.google.com/group/micro...rowse_thread/t.... > > >> Lynn > > > Thank you Lynn, I'll give it a deep look later (i'm copying the codes > > right now to a new project and will try to compile a test program > > later). > > But unfortunatelly this is a little urgent and I don't have much able > > time to learn everything of such a complex code, I have a program that > > generates a datasheet in XLS using the OLE automation, but I have to > > add borders to a big table and it proves to be quite hard to me right > > now mainly because I'm not usued to do codes for computers (I'm a > > firmware developer for microcontrolers and embed devices). > > > I'm basically using the example that is in msdn about OLE automation > > (automation without using MFC and #import), so its basically: > > > HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, > > LPOLESTR ptName, int cArgs...) { > > ... > > } > > > and things like this in the main() > > > * * // Get ActiveSheet object > > * * IDispatch *pXlSheet; > > * * { > > * * * *VARIANT result; > > * * * *VariantInit(&result); > > * * * *AutoWrap(DISPATCH_PROPERTYGET,&result, pXlApp, L"ActiveSheet", > > 0); > > * * * *pXlSheet = result.pdispVal; > > * * } > > > the program is working fine right now, except by the borders that I > > need in the ranges: > > > Range("B10:I50").Select > > Range("B60:I100").Select > > Range("B110:I150").Select > > Range("B160:I200").Select > > > in anyway, I will understand if you don't want to code it for me or to > > point where I may find it in the code you just showed me. > > That is the problem. *There is a LOT of coding items that you have > to handle in order to initialize the interface. *This is basically > the sequence of events: > > *> // fm2n_old.cpp > > *> // The OLE Automation interface to Excel is mostly written using: > *> // "How to automate Excel from C++ without using MFC or #import" > *> //http://support.microsoft.com/kb/216686 > > // *to call this code : > // * * * * * * *if (ConnectToNotebook (notebook, RunInTestMode, true)) > // * * * * * * *{ > // * * * * * * * * * * *// *do your excel data transfer here > // * * * * * * * * * * *DisconnectFromNotebook (RunInTestMode); > // * * * * * * *} > > // *see getCellInfo or putCellInfo for single cell data transfer examples > > // *see PutRowInTable for bulk transfer example, note that the more data can > // * * *be transferred at one time, the faster the data transfer is > > For formatting a range, see the functions: > * * int setRangeFont (std::string rangeValue, std::string fontNameValue, int boldValue, int sizeValue, int colorValue); > * * int SetRangeWidthAlignment (std::string rangeValue, int columnWidthValue, int horizontalAlignmentValue); > > The C++ OLE automation interface for Excel (or any other OLE server) > is very involved. > > Lynn I solved most of the erros, but I still experience the following errors Error 1 error C2065: 'MaxItemsInRow' : undeclared identifier e:\users \user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.h 32 Error 2 error C2065: 'MaxLineChunks' : undeclared identifier e:\users \user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.h 38 Error 3 error C3861: 'SetUnitsCase': identifier not found e:\users\user \documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 1851 Error 4 error C3861: 'SetUnitsCase': identifier not found e:\users\user \documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 1864 Error 5 error C3861: 'SetUnitsCase': identifier not found e:\users\user \documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 1879 |
|
||
|
||||
|
Lynn McGuire
Guest
Posts: n/a
|
On 1/18/2011 12:53 PM, Lucas Coppio wrote:
> On Jan 18, 4:18 pm, Lynn McGuire<l...@winsim.com> wrote: >> On 1/18/2011 11:10 AM, Lucas Coppio wrote: >> >> >> >>> On 17 jan, 19:01, Lynn McGuire<l...@winsim.com> wrote: >>>> On 1/17/2011 1:49 PM, Lucas Coppio wrote: >> >>>>> Hi, ive done a small program using OLE automation but I still don't >>>>> know how to put borders on some cells >>>>> This is the MACRO code, but I need to translate it to something the VC+ >>>>> +/OLE2 can understand, but I have no clue on how to do that. >> >>>>> Sub Macro1() >>>>> ' >>>>> ' Macro1 Macro >>>>> ' >> >>>>> ' >>>>> Range("B10:I50").Select >>>>> Selection.Borders(xlDiagonalDown).LineStyle = xlNone >>>>> Selection.Borders(xlDiagonalUp).LineStyle = xlNone >>>>> With Selection.Borders(xlEdgeLeft) >>>>> .LineStyle = xlContinuous >>>>> .ColorIndex = 0 >>>>> .TintAndShade = 0 >>>>> .Weight = xlThin >>>>> End With >>>>> With Selection.Borders(xlEdgeTop) >>>>> .LineStyle = xlContinuous >>>>> .ColorIndex = 0 >>>>> .TintAndShade = 0 >>>>> .Weight = xlThin >>>>> End With >>>>> With Selection.Borders(xlEdgeBottom) >>>>> .LineStyle = xlContinuous >>>>> .ColorIndex = 0 >>>>> .TintAndShade = 0 >>>>> .Weight = xlThin >>>>> End With >>>>> With Selection.Borders(xlEdgeRight) >>>>> .LineStyle = xlContinuous >>>>> .ColorIndex = 0 >>>>> .TintAndShade = 0 >>>>> .Weight = xlThin >>>>> End With >>>>> With Selection.Borders(xlInsideVertical) >>>>> .LineStyle = xlContinuous >>>>> .ColorIndex = 0 >>>>> .TintAndShade = 0 >>>>> .Weight = xlThin >>>>> End With >>>>> With Selection.Borders(xlInsideHorizontal) >>>>> .LineStyle = xlContinuous >>>>> .ColorIndex = 0 >>>>> .TintAndShade = 0 >>>>> .Weight = xlThin >>>>> End With >>>>> End Sub >> >>>> Here is a full C++ OLE Automation interface for Excel: >> >>>> http://groups.google.com/group/micro...rowse_thread/t... >> >>>> Lynn >> >>> Thank you Lynn, I'll give it a deep look later (i'm copying the codes >>> right now to a new project and will try to compile a test program >>> later). >>> But unfortunatelly this is a little urgent and I don't have much able >>> time to learn everything of such a complex code, I have a program that >>> generates a datasheet in XLS using the OLE automation, but I have to >>> add borders to a big table and it proves to be quite hard to me right >>> now mainly because I'm not usued to do codes for computers (I'm a >>> firmware developer for microcontrolers and embed devices). >> >>> I'm basically using the example that is in msdn about OLE automation >>> (automation without using MFC and #import), so its basically: >> >>> HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, >>> LPOLESTR ptName, int cArgs...) { >>> ... >>> } >> >>> and things like this in the main() >> >>> // Get ActiveSheet object >>> IDispatch *pXlSheet; >>> { >>> VARIANT result; >>> VariantInit(&result); >>> AutoWrap(DISPATCH_PROPERTYGET,&result, pXlApp, L"ActiveSheet", >>> 0); >>> pXlSheet = result.pdispVal; >>> } >> >>> the program is working fine right now, except by the borders that I >>> need in the ranges: >> >>> Range("B10:I50").Select >>> Range("B60:I100").Select >>> Range("B110:I150").Select >>> Range("B160:I200").Select >> >>> in anyway, I will understand if you don't want to code it for me or to >>> point where I may find it in the code you just showed me. >> >> That is the problem. There is a LOT of coding items that you have >> to handle in order to initialize the interface. This is basically >> the sequence of events: >> >> > // fm2n_old.cpp >> >> > // The OLE Automation interface to Excel is mostly written using: >> > // "How to automate Excel from C++ without using MFC or #import" >> > //http://support.microsoft.com/kb/216686 >> >> // to call this code : >> // if (ConnectToNotebook (notebook, RunInTestMode, true)) >> // { >> // // do your excel data transfer here >> // DisconnectFromNotebook (RunInTestMode); >> // } >> >> // see getCellInfo or putCellInfo for single cell data transfer examples >> >> // see PutRowInTable for bulk transfer example, note that the more data can >> // be transferred at one time, the faster the data transfer is >> >> For formatting a range, see the functions: >> int setRangeFont (std::string rangeValue, std::string fontNameValue, int boldValue, int sizeValue, int colorValue); >> int SetRangeWidthAlignment (std::string rangeValue, int columnWidthValue, int horizontalAlignmentValue); >> >> The C++ OLE automation interface for Excel (or any other OLE server) >> is very involved. >> >> Lynn > > I solved most of the erros, but I still experience the following > errors > > Error 1 error C2065: 'MaxItemsInRow' : undeclared identifier e:\users > \user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.h > 32 > Error 2 error C2065: 'MaxLineChunks' : undeclared identifier e:\users > \user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.h > 38 > Error 3 error C3861: 'SetUnitsCase': identifier not found e:\users\user > \documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 1851 > Error 4 error C3861: 'SetUnitsCase': identifier not found e:\users\user > \documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 1864 > Error 5 error C3861: 'SetUnitsCase': identifier not found e:\users\user > \documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 1879 BTW, I am still using Visual Studio 2005 so this code is not VSVC 2008 tested. MaxItemsInRow is an internal item that you should be able to get rid of. MaxLineChunks is 20. SetUnitsCase is an internal item that you should be able to replace with std::string SetUnitsCase (std::string str) { return str; } Lynn |
|
||
|
||||
|
Lucas Coppio
Guest
Posts: n/a
|
On Jan 18, 6:06*pm, Lynn McGuire <l...@winsim.com> wrote:
> On 1/18/2011 12:53 PM, Lucas Coppio wrote: > > > > > On Jan 18, 4:18 pm, Lynn McGuire<l...@winsim.com> *wrote: > >> On 1/18/2011 11:10 AM, Lucas Coppio wrote: > > >>> On 17 jan, 19:01, Lynn McGuire<l...@winsim.com> * *wrote: > >>>> On 1/17/2011 1:49 PM, Lucas Coppio wrote: > > >>>>> Hi, ive done a small program using OLE automation but I still don't > >>>>> know how to put borders on some cells > >>>>> This is the MACRO code, but I need to translate it to something theVC+ > >>>>> +/OLE2 can understand, but I have *no clue on how to do that. > > >>>>> Sub Macro1() > >>>>> ' > >>>>> ' Macro1 Macro > >>>>> ' > > >>>>> ' > >>>>> * * * *Range("B10:I50").Select > >>>>> * * * *Selection.Borders(xlDiagonalDown).LineStyle = xlNone > >>>>> * * * *Selection.Borders(xlDiagonalUp).LineStyle = xlNone > >>>>> * * * *With Selection.Borders(xlEdgeLeft) > >>>>> * * * * * *.LineStyle = xlContinuous > >>>>> * * * * * *.ColorIndex = 0 > >>>>> * * * * * *.TintAndShade = 0 > >>>>> * * * * * *.Weight = xlThin > >>>>> * * * *End With > >>>>> * * * *With Selection.Borders(xlEdgeTop) > >>>>> * * * * * *.LineStyle = xlContinuous > >>>>> * * * * * *.ColorIndex = 0 > >>>>> * * * * * *.TintAndShade = 0 > >>>>> * * * * * *.Weight = xlThin > >>>>> * * * *End With > >>>>> * * * *With Selection.Borders(xlEdgeBottom) > >>>>> * * * * * *.LineStyle = xlContinuous > >>>>> * * * * * *.ColorIndex = 0 > >>>>> * * * * * *.TintAndShade = 0 > >>>>> * * * * * *.Weight = xlThin > >>>>> * * * *End With > >>>>> * * * *With Selection.Borders(xlEdgeRight) > >>>>> * * * * * *.LineStyle = xlContinuous > >>>>> * * * * * *.ColorIndex = 0 > >>>>> * * * * * *.TintAndShade = 0 > >>>>> * * * * * *.Weight = xlThin > >>>>> * * * *End With > >>>>> * * * *With Selection.Borders(xlInsideVertical) > >>>>> * * * * * *.LineStyle = xlContinuous > >>>>> * * * * * *.ColorIndex = 0 > >>>>> * * * * * *.TintAndShade = 0 > >>>>> * * * * * *.Weight = xlThin > >>>>> * * * *End With > >>>>> * * * *With Selection.Borders(xlInsideHorizontal) > >>>>> * * * * * *.LineStyle = xlContinuous > >>>>> * * * * * *.ColorIndex = 0 > >>>>> * * * * * *.TintAndShade = 0 > >>>>> * * * * * *.Weight = xlThin > >>>>> * * * *End With > >>>>> End Sub > > >>>> Here is a full C++ OLE Automation interface for Excel: > > >>>>http://groups.google.com/group/micro...rowse_thread/t.... > > >>>> Lynn > > >>> Thank you Lynn, I'll give it a deep look later (i'm copying the codes > >>> right now to a new project and will try to compile a test program > >>> later). > >>> But unfortunatelly this is a little urgent and I don't have much able > >>> time to learn everything of such a complex code, I have a program that > >>> generates a datasheet in XLS using the OLE automation, but I have to > >>> add borders to a big table and it proves to be quite hard to me right > >>> now mainly because I'm not usued to do codes for computers (I'm a > >>> firmware developer for microcontrolers and embed devices). > > >>> I'm basically using the example that is in msdn about OLE automation > >>> (automation without using MFC and #import), so its basically: > > >>> HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, > >>> LPOLESTR ptName, int cArgs...) { > >>> ... > >>> } > > >>> and things like this in the main() > > >>> * * *// Get ActiveSheet object > >>> * * *IDispatch *pXlSheet; > >>> * * *{ > >>> * * * * VARIANT result; > >>> * * * * VariantInit(&result); > >>> * * * * AutoWrap(DISPATCH_PROPERTYGET,&result, pXlApp, L"ActiveSheet", > >>> 0); > >>> * * * * pXlSheet = result.pdispVal; > >>> * * *} > > >>> the program is working fine right now, except by the borders that I > >>> need in the ranges: > > >>> Range("B10:I50").Select > >>> Range("B60:I100").Select > >>> Range("B110:I150").Select > >>> Range("B160:I200").Select > > >>> in anyway, I will understand if you don't want to code it for me or to > >>> point where I may find it in the code you just showed me. > > >> That is the problem. *There is a LOT of coding items that you have > >> to handle in order to initialize the interface. *This is basically > >> the sequence of events: > > >> * > *// fm2n_old.cpp > > >> * > *// The OLE Automation interface to Excel is mostly written using: > >> * > *// "How to automate Excel from C++ without using MFC or #import" > >> * > *//http://support.microsoft.com/kb/216686 > > >> // *to call this code : > >> // * * * * * * *if (ConnectToNotebook (notebook, RunInTestMode, true)) > >> // * * * * * * *{ > >> // * * * * * * * * * * *// *do your excel datatransfer here > >> // * * * * * * * * * * *DisconnectFromNotebook (RunInTestMode); > >> // * * * * * * *} > > >> // *see getCellInfo or putCellInfo for single cell data transfer examples > > >> // *see PutRowInTable for bulk transfer example, note that the more data can > >> // * * *be transferred at one time, the faster the data transferis > > >> For formatting a range, see the functions: > >> * * *int setRangeFont (std::string rangeValue, std::string fontNameValue, int boldValue, int sizeValue, int colorValue); > >> * * *int SetRangeWidthAlignment (std::string rangeValue, int columnWidthValue, int horizontalAlignmentValue); > > >> The C++ OLE automation interface for Excel (or any other OLE server) > >> is very involved. > > >> Lynn > > > I solved most of the erros, but I still experience the following > > errors > > > Error * * *1 * * * error C2065: 'MaxItemsInRow' : undeclared identifier * *e:\users > > \user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.h > > 32 > > Error * * *2 * * * error C2065: 'MaxLineChunks' : undeclared identifier * *e:\users > > \user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.h > > 38 > > Error * * *3 * * * error C3861: 'SetUnitsCase': identifier not found * * * e:\users\user > > \documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp *1851 > > Error * * *4 * * * error C3861: 'SetUnitsCase': identifier not found * * * e:\users\user > > \documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp *1864 > > Error * * *5 * * * error C3861: 'SetUnitsCase': identifier not found * * * e:\users\user > > \documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp *1879 > > BTW, I am still using Visual Studio 2005 so this code is not VSVC 2008 > tested. > > MaxItemsInRow is an internal item that you should be able to get rid of. > > MaxLineChunks is 20. > > SetUnitsCase is an internal item that you should be able to replace with > > std::string SetUnitsCase (std::string str) > { > * * return str; > > } > > Lynn yes I managed that, but now I'm receiving an error from my linker :\ Error 1 error LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > notebook" (?notebook@@3V?$basic_string@DU? $char_traits@D@std@@V?$allocator@D@2@@std@@A) XlsCpp.obj |
|
||
|
||||
|
Lucas Coppio
Guest
Posts: n/a
|
On Jan 18, 6:06*pm, Lynn McGuire <l...@winsim.com> wrote:
> On 1/18/2011 12:53 PM, Lucas Coppio wrote: > > > > > On Jan 18, 4:18 pm, Lynn McGuire<l...@winsim.com> *wrote: > >> On 1/18/2011 11:10 AM, Lucas Coppio wrote: > > >>> On 17 jan, 19:01, Lynn McGuire<l...@winsim.com> * *wrote: > >>>> On 1/17/2011 1:49 PM, Lucas Coppio wrote: > > >>>>> Hi, ive done a small program using OLE automation but I still don't > >>>>> know how to put borders on some cells > >>>>> This is the MACRO code, but I need to translate it to something theVC+ > >>>>> +/OLE2 can understand, but I have *no clue on how to do that. > > >>>>> Sub Macro1() > >>>>> ' > >>>>> ' Macro1 Macro > >>>>> ' > > >>>>> ' > >>>>> * * * *Range("B10:I50").Select > >>>>> * * * *Selection.Borders(xlDiagonalDown).LineStyle = xlNone > >>>>> * * * *Selection.Borders(xlDiagonalUp).LineStyle = xlNone > >>>>> * * * *With Selection.Borders(xlEdgeLeft) > >>>>> * * * * * *.LineStyle = xlContinuous > >>>>> * * * * * *.ColorIndex = 0 > >>>>> * * * * * *.TintAndShade = 0 > >>>>> * * * * * *.Weight = xlThin > >>>>> * * * *End With > >>>>> * * * *With Selection.Borders(xlEdgeTop) > >>>>> * * * * * *.LineStyle = xlContinuous > >>>>> * * * * * *.ColorIndex = 0 > >>>>> * * * * * *.TintAndShade = 0 > >>>>> * * * * * *.Weight = xlThin > >>>>> * * * *End With > >>>>> * * * *With Selection.Borders(xlEdgeBottom) > >>>>> * * * * * *.LineStyle = xlContinuous > >>>>> * * * * * *.ColorIndex = 0 > >>>>> * * * * * *.TintAndShade = 0 > >>>>> * * * * * *.Weight = xlThin > >>>>> * * * *End With > >>>>> * * * *With Selection.Borders(xlEdgeRight) > >>>>> * * * * * *.LineStyle = xlContinuous > >>>>> * * * * * *.ColorIndex = 0 > >>>>> * * * * * *.TintAndShade = 0 > >>>>> * * * * * *.Weight = xlThin > >>>>> * * * *End With > >>>>> * * * *With Selection.Borders(xlInsideVertical) > >>>>> * * * * * *.LineStyle = xlContinuous > >>>>> * * * * * *.ColorIndex = 0 > >>>>> * * * * * *.TintAndShade = 0 > >>>>> * * * * * *.Weight = xlThin > >>>>> * * * *End With > >>>>> * * * *With Selection.Borders(xlInsideHorizontal) > >>>>> * * * * * *.LineStyle = xlContinuous > >>>>> * * * * * *.ColorIndex = 0 > >>>>> * * * * * *.TintAndShade = 0 > >>>>> * * * * * *.Weight = xlThin > >>>>> * * * *End With > >>>>> End Sub > > >>>> Here is a full C++ OLE Automation interface for Excel: > > >>>>http://groups.google.com/group/micro...rowse_thread/t.... > > >>>> Lynn > > >>> Thank you Lynn, I'll give it a deep look later (i'm copying the codes > >>> right now to a new project and will try to compile a test program > >>> later). > >>> But unfortunatelly this is a little urgent and I don't have much able > >>> time to learn everything of such a complex code, I have a program that > >>> generates a datasheet in XLS using the OLE automation, but I have to > >>> add borders to a big table and it proves to be quite hard to me right > >>> now mainly because I'm not usued to do codes for computers (I'm a > >>> firmware developer for microcontrolers and embed devices). > > >>> I'm basically using the example that is in msdn about OLE automation > >>> (automation without using MFC and #import), so its basically: > > >>> HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, > >>> LPOLESTR ptName, int cArgs...) { > >>> ... > >>> } > > >>> and things like this in the main() > > >>> * * *// Get ActiveSheet object > >>> * * *IDispatch *pXlSheet; > >>> * * *{ > >>> * * * * VARIANT result; > >>> * * * * VariantInit(&result); > >>> * * * * AutoWrap(DISPATCH_PROPERTYGET,&result, pXlApp, L"ActiveSheet", > >>> 0); > >>> * * * * pXlSheet = result.pdispVal; > >>> * * *} > > >>> the program is working fine right now, except by the borders that I > >>> need in the ranges: > > >>> Range("B10:I50").Select > >>> Range("B60:I100").Select > >>> Range("B110:I150").Select > >>> Range("B160:I200").Select > > >>> in anyway, I will understand if you don't want to code it for me or to > >>> point where I may find it in the code you just showed me. > > >> That is the problem. *There is a LOT of coding items that you have > >> to handle in order to initialize the interface. *This is basically > >> the sequence of events: > > >> * > *// fm2n_old.cpp > > >> * > *// The OLE Automation interface to Excel is mostly written using: > >> * > *// "How to automate Excel from C++ without using MFC or #import" > >> * > *//http://support.microsoft.com/kb/216686 > > >> // *to call this code : > >> // * * * * * * *if (ConnectToNotebook (notebook, RunInTestMode, true)) > >> // * * * * * * *{ > >> // * * * * * * * * * * *// *do your excel datatransfer here > >> // * * * * * * * * * * *DisconnectFromNotebook (RunInTestMode); > >> // * * * * * * *} > > >> // *see getCellInfo or putCellInfo for single cell data transfer examples > > >> // *see PutRowInTable for bulk transfer example, note that the more data can > >> // * * *be transferred at one time, the faster the data transferis > > >> For formatting a range, see the functions: > >> * * *int setRangeFont (std::string rangeValue, std::string fontNameValue, int boldValue, int sizeValue, int colorValue); > >> * * *int SetRangeWidthAlignment (std::string rangeValue, int columnWidthValue, int horizontalAlignmentValue); > > >> The C++ OLE automation interface for Excel (or any other OLE server) > >> is very involved. > > >> Lynn > > > I solved most of the erros, but I still experience the following > > errors > > > Error * * *1 * * * error C2065: 'MaxItemsInRow' : undeclared identifier * *e:\users > > \user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.h > > 32 > > Error * * *2 * * * error C2065: 'MaxLineChunks' : undeclared identifier * *e:\users > > \user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.h > > 38 > > Error * * *3 * * * error C3861: 'SetUnitsCase': identifier not found * * * e:\users\user > > \documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp *1851 > > Error * * *4 * * * error C3861: 'SetUnitsCase': identifier not found * * * e:\users\user > > \documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp *1864 > > Error * * *5 * * * error C3861: 'SetUnitsCase': identifier not found * * * e:\users\user > > \documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp *1879 > > BTW, I am still using Visual Studio 2005 so this code is not VSVC 2008 > tested. > > MaxItemsInRow is an internal item that you should be able to get rid of. > > MaxLineChunks is 20. > > SetUnitsCase is an internal item that you should be able to replace with > > std::string SetUnitsCase (std::string str) > { > * * return str; > > } > > Lynn yes I managed that, but now I'm receiving an error from my linker :\ Error 1 error LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > notebook" (?notebook@@3V?$basic_string@DU? $char_traits@D@std@@V?$allocator@D@2@@std@@A) XlsCpp.obj |
|
||
|
||||
|
Lynn McGuire
Guest
Posts: n/a
|
"Lucas Coppio" <(E-Mail Removed)> wrote in message news:4d80829c-a2da-45f5-9cd0-(E-Mail Removed)...
On Jan 18, 6:06 pm, Lynn McGuire <l...@winsim.com> wrote: > On 1/18/2011 12:53 PM, Lucas Coppio wrote: > > > > > On Jan 18, 4:18 pm, Lynn McGuire<l...@winsim.com> wrote: > >> On 1/18/2011 11:10 AM, Lucas Coppio wrote: > > >>> On 17 jan, 19:01, Lynn McGuire<l...@winsim.com> wrote: > >>>> On 1/17/2011 1:49 PM, Lucas Coppio wrote: > > >>>>> Hi, ive done a small program using OLE automation but I still don't > >>>>> know how to put borders on some cells > >>>>> This is the MACRO code, but I need to translate it to something the VC+ > >>>>> +/OLE2 can understand, but I have no clue on how to do that. > > >>>>> Sub Macro1() > >>>>> ' > >>>>> ' Macro1 Macro > >>>>> ' > > >>>>> ' > >>>>> Range("B10:I50").Select > >>>>> Selection.Borders(xlDiagonalDown).LineStyle = xlNone > >>>>> Selection.Borders(xlDiagonalUp).LineStyle = xlNone > >>>>> With Selection.Borders(xlEdgeLeft) > >>>>> .LineStyle = xlContinuous > >>>>> .ColorIndex = 0 > >>>>> .TintAndShade = 0 > >>>>> .Weight = xlThin > >>>>> End With > >>>>> With Selection.Borders(xlEdgeTop) > >>>>> .LineStyle = xlContinuous > >>>>> .ColorIndex = 0 > >>>>> .TintAndShade = 0 > >>>>> .Weight = xlThin > >>>>> End With > >>>>> With Selection.Borders(xlEdgeBottom) > >>>>> .LineStyle = xlContinuous > >>>>> .ColorIndex = 0 > >>>>> .TintAndShade = 0 > >>>>> .Weight = xlThin > >>>>> End With > >>>>> With Selection.Borders(xlEdgeRight) > >>>>> .LineStyle = xlContinuous > >>>>> .ColorIndex = 0 > >>>>> .TintAndShade = 0 > >>>>> .Weight = xlThin > >>>>> End With > >>>>> With Selection.Borders(xlInsideVertical) > >>>>> .LineStyle = xlContinuous > >>>>> .ColorIndex = 0 > >>>>> .TintAndShade = 0 > >>>>> .Weight = xlThin > >>>>> End With > >>>>> With Selection.Borders(xlInsideHorizontal) > >>>>> .LineStyle = xlContinuous > >>>>> .ColorIndex = 0 > >>>>> .TintAndShade = 0 > >>>>> .Weight = xlThin > >>>>> End With > >>>>> End Sub > > >>>> Here is a full C++ OLE Automation interface for Excel: > > >>>>http://groups.google.com/group/micro...rowse_thread/t... > > >>>> Lynn > > >>> Thank you Lynn, I'll give it a deep look later (i'm copying the codes > >>> right now to a new project and will try to compile a test program > >>> later). > >>> But unfortunatelly this is a little urgent and I don't have much able > >>> time to learn everything of such a complex code, I have a program that > >>> generates a datasheet in XLS using the OLE automation, but I have to > >>> add borders to a big table and it proves to be quite hard to me right > >>> now mainly because I'm not usued to do codes for computers (I'm a > >>> firmware developer for microcontrolers and embed devices). > > >>> I'm basically using the example that is in msdn about OLE automation > >>> (automation without using MFC and #import), so its basically: > > >>> HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, > >>> LPOLESTR ptName, int cArgs...) { > >>> ... > >>> } > > >>> and things like this in the main() > > >>> // Get ActiveSheet object > >>> IDispatch *pXlSheet; > >>> { > >>> VARIANT result; > >>> VariantInit(&result); > >>> AutoWrap(DISPATCH_PROPERTYGET,&result, pXlApp, L"ActiveSheet", > >>> 0); > >>> pXlSheet = result.pdispVal; > >>> } > > >>> the program is working fine right now, except by the borders that I > >>> need in the ranges: > > >>> Range("B10:I50").Select > >>> Range("B60:I100").Select > >>> Range("B110:I150").Select > >>> Range("B160:I200").Select > > >>> in anyway, I will understand if you don't want to code it for me or to > >>> point where I may find it in the code you just showed me. > > >> That is the problem. There is a LOT of coding items that you have > >> to handle in order to initialize the interface. This is basically > >> the sequence of events: > > >> > // fm2n_old.cpp > > >> > // The OLE Automation interface to Excel is mostly written using: > >> > // "How to automate Excel from C++ without using MFC or #import" > >> > //http://support.microsoft.com/kb/216686 > > >> // to call this code : > >> // if (ConnectToNotebook (notebook, RunInTestMode, true)) > >> // { > >> // // do your excel data transfer here > >> // DisconnectFromNotebook (RunInTestMode); > >> // } > > >> // see getCellInfo or putCellInfo for single cell data transfer examples > > >> // see PutRowInTable for bulk transfer example, note that the more data can > >> // be transferred at one time, the faster the data transfer is > > >> For formatting a range, see the functions: > >> int setRangeFont (std::string rangeValue, std::string fontNameValue, int boldValue, int sizeValue, int colorValue); > >> int SetRangeWidthAlignment (std::string rangeValue, int columnWidthValue, int horizontalAlignmentValue); > > >> The C++ OLE automation interface for Excel (or any other OLE server) > >> is very involved. > > >> Lynn > > > I solved most of the erros, but I still experience the following > > errors > > > Error 1 error C2065: 'MaxItemsInRow' : undeclared identifier e:\users > > \user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.h > > 32 > > Error 2 error C2065: 'MaxLineChunks' : undeclared identifier e:\users > > \user\documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.h > > 38 > > Error 3 error C3861: 'SetUnitsCase': identifier not found e:\users\user > > \documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 1851 > > Error 4 error C3861: 'SetUnitsCase': identifier not found e:\users\user > > \documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 1864 > > Error 5 error C3861: 'SetUnitsCase': identifier not found e:\users\user > > \documents\visual studio 2008\projects\xlscpp\xlscpp\fm2n_old.cpp 1879 > > BTW, I am still using Visual Studio 2005 so this code is not VSVC 2008 > tested. > > MaxItemsInRow is an internal item that you should be able to get rid of. > > MaxLineChunks is 20. > > SetUnitsCase is an internal item that you should be able to replace with > > std::string SetUnitsCase (std::string str) > { > return str; > > } > > Lynn yes I managed that, but now I'm receiving an error from my linker :\ Error 1 error LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > notebook" (?notebook@@3V?$basic_string@DU? $char_traits@D@std@@V?$allocator@D@2@@std@@A) XlsCpp.obj =================================================== Just create a std::string notebook global variable. Man, my posted code was not clean ! Lynn |
|
||
|
||||
|
|
|
| |
![]() |
| Thread Tools | |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Conditional Format Borders | clark-ee | Microsoft Excel Misc | 1 | 26th Oct 2008 01:21 AM |
| Format cells with borders | =?Utf-8?B?Smlt?= | Microsoft Excel Misc | 3 | 10th Jun 2007 02:24 AM |
| Format Borders | STEVEB | Microsoft Excel Programming | 5 | 29th Jul 2005 04:46 AM |
| Why does page borders not appear in my borders and shading format. | =?Utf-8?B?TW93Z2xp?= | Microsoft Word Document Management | 4 | 11th Jan 2005 08:40 PM |
| Format Borders too big for printer | David Reisig | Microsoft Word New Users | 3 | 16th Nov 2003 12:07 AM |
Powered by vBulletin®. Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2010, Crawlability, Inc. |




