My export via AlphaDAO and my Modification code works on my system using Microsoft Excel Starter 2010 (I like using the least robust program
to try and make sure that what I create will be compatible with whatever my clients have). The computer I am trying to get the code to work on has Excel 2007.
I believe (correct me if wrong) that seeing the entire code is unnecessary as the errors/omissions occur prior to any code running other than the
connections to Excel. The error in exporting is strange (only one of two sheets) as I have created code both ways using AlphaDAO export to 2003
and 2007 Excel and the only code difference is within the connectionString.
I tried with .xls and .xlsx
I tried dim Doc as Office::ExcelDocument and dim Doc as Office::Excel2003Document
above with ALL permutations...only listing the ones that are not obviously incorrect (I think!)
'=======================================================================================
Alpha DAO export connection:
Excel_tbl is the variable with the full path of the file and the strings were created by Alpha and work on my system.
connectionString = "{A5API='Excel',A5Syntax='Excel',FileName="+Excel_tbl+", A5ExcelVersion=2007}"
OR
connectionString = "{A5API='Excel',A5Syntax='Excel',FileName="+Excel_tbl+", A5ExcelVersion=2003}"
'=========================================
Excel Modification code:
'only one of the Doc as Office::..... used of course at any given test
dim Doc as Office::ExcelDocument 'used for 2007
'dim Doc as Office::Excel2003Document
dim Sheet as Office::Spreadsheet
dim SheetName as c = ""
SheetName=alltrim(var->sh_name) 'sh_name is the variable that has the sheet name...verified to be what is produced by the export
'Excel_pth is a variable for the full path obtained via a function argument that has the Modification code...and is exactly the same as the AlphaDAO connection string path.
if Doc.Load(Excel_pth)
if Doc.FindSheet(Sheet,SheetName)
'==================================================
ERRORS:
When creating .xlsx and A5ExcelVersion=2007 and using Office::Excel2003Document --well, obviously didn't (and shouldn't) work! and did not
include the other permutations that should not work
'--------------------------------------------------------------------------------------------------------------
When creating .xls and A5ExcelVersion=2003 and using Office::Excel2003Document -- Only creates one sheet(instead of two) and the
modification code brings up an error when getting to: dim Doc as Office::Excel2003Document. The error is "Type is not defined"
'--------------------------------------------------------------------------------------------------------------
When creating .xls and A5ExcelVersion=2007 and using Office::ExcelDocument -- Only creates one sheet(instead of two) and the modification code cannot find the SheetName....and have tried using both versions of Doc...Excel2003Document and ExcelDocument.
But without having both sheets the Modification code is not the first concern here...just the creation of only one sheet...if this is the way to approach this issue then there are two issues most likely.
'--------------------------------------------------------------------------------------------------------------
When creating .xlsx and A5ExcelVersion=2007, and using Office::ExcelDocument -- goes to Doc.FindSheet(Sheet,SheetName) and does not
find it. I have verified that the Sheet name is correct (and have used and not used alltrim() on the Sheet name. I noticed that the 2007 version has
[Compatibility mode] as part of the spreadsheet title....and added that as well which did not help.
This makes sense in that eliminating the Excel Modification code and opening up the Excel file an error comes up that either the file is corrupt or
that the file extension does not match the format of the file. This appears to be the main issue and think if this is fixed that my modification code
will work.
'===========================================================
One out of the last three should work....just don't know which one I should concentrate on and what to try next in any of them.
Let me know of any additional information wanted...entire code is no problem but think it would confuse what I believe to be the main issues.
to try and make sure that what I create will be compatible with whatever my clients have). The computer I am trying to get the code to work on has Excel 2007.
I believe (correct me if wrong) that seeing the entire code is unnecessary as the errors/omissions occur prior to any code running other than the
connections to Excel. The error in exporting is strange (only one of two sheets) as I have created code both ways using AlphaDAO export to 2003
and 2007 Excel and the only code difference is within the connectionString.
I tried with .xls and .xlsx
I tried dim Doc as Office::ExcelDocument and dim Doc as Office::Excel2003Document
above with ALL permutations...only listing the ones that are not obviously incorrect (I think!)
'=======================================================================================
Alpha DAO export connection:
Excel_tbl is the variable with the full path of the file and the strings were created by Alpha and work on my system.
connectionString = "{A5API='Excel',A5Syntax='Excel',FileName="+Excel_tbl+", A5ExcelVersion=2007}"
OR
connectionString = "{A5API='Excel',A5Syntax='Excel',FileName="+Excel_tbl+", A5ExcelVersion=2003}"
'=========================================
Excel Modification code:
'only one of the Doc as Office::..... used of course at any given test
dim Doc as Office::ExcelDocument 'used for 2007
'dim Doc as Office::Excel2003Document
dim Sheet as Office::Spreadsheet
dim SheetName as c = ""
SheetName=alltrim(var->sh_name) 'sh_name is the variable that has the sheet name...verified to be what is produced by the export
'Excel_pth is a variable for the full path obtained via a function argument that has the Modification code...and is exactly the same as the AlphaDAO connection string path.
if Doc.Load(Excel_pth)
if Doc.FindSheet(Sheet,SheetName)
'==================================================
ERRORS:
When creating .xlsx and A5ExcelVersion=2007 and using Office::Excel2003Document --well, obviously didn't (and shouldn't) work! and did not
include the other permutations that should not work
'--------------------------------------------------------------------------------------------------------------
When creating .xls and A5ExcelVersion=2003 and using Office::Excel2003Document -- Only creates one sheet(instead of two) and the
modification code brings up an error when getting to: dim Doc as Office::Excel2003Document. The error is "Type is not defined"
'--------------------------------------------------------------------------------------------------------------
When creating .xls and A5ExcelVersion=2007 and using Office::ExcelDocument -- Only creates one sheet(instead of two) and the modification code cannot find the SheetName....and have tried using both versions of Doc...Excel2003Document and ExcelDocument.
But without having both sheets the Modification code is not the first concern here...just the creation of only one sheet...if this is the way to approach this issue then there are two issues most likely.
'--------------------------------------------------------------------------------------------------------------
When creating .xlsx and A5ExcelVersion=2007, and using Office::ExcelDocument -- goes to Doc.FindSheet(Sheet,SheetName) and does not
find it. I have verified that the Sheet name is correct (and have used and not used alltrim() on the Sheet name. I noticed that the 2007 version has
[Compatibility mode] as part of the spreadsheet title....and added that as well which did not help.
This makes sense in that eliminating the Excel Modification code and opening up the Excel file an error comes up that either the file is corrupt or
that the file extension does not match the format of the file. This appears to be the main issue and think if this is fixed that my modification code
will work.
'===========================================================
One out of the last three should work....just don't know which one I should concentrate on and what to try next in any of them.
Let me know of any additional information wanted...entire code is no problem but think it would confuse what I believe to be the main issues.
Comment