Alpha Video Training
Page 1 of 2 12 LastLast
Results 1 to 30 of 42

Thread: Export to Excel Tabs?

  1. #1
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Export to Excel Tabs?

    Hi,

    I have searched and know that it has been mentioned before but cant find answer.

    Two part question:

    How do you export to a named starting cell on an excel spreadsheet?

    eg A6.

    Also, how do you export to a named cell and Named Tab in an Excel spreadsheet?
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    Other than OLE or using OLE?
    There can be only one.

  3. #3
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: Export to Excel Tabs?

    Hi Stan,

    By what ever is best.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  4. #4
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    Create a spreadsheet in your c:\ root directory named keith's sheet.xls.
    Create this function in AlphaSports.

    Code:
    FUNCTION ex_keith AS L (excelname AS C, newname AS C )
    	ex_keith = .F.
    	Dim xlApp as p
    	dim myCell as c
    	xlApp = ole.create("Excel.Application")
    	xlApp.Workbooks.Open(excelname)
    	'xlApp.Visible = .T. 'comment this line out if you don't want to see Excel
    	tbl = table.open("customer")
    	query.filter = ".T."
    	query.order = "recno()"
    	query.options = "I"
    	query.description = "Temporary Query"
    	ix = tbl.query_create()
    	recs = ix.records_get()
    	tbl.fetch_first()
    	start_cell = 6
    	FOR t = 0 TO recs
    		xlApp.Range("A"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.firstname)
    		xlApp.Range("B"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.lastname)
    		xlApp.Range("C"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.email)
    		tbl.fetch_next()
    	NEXT t
            tbl.close()
    	xlApp.Columns("A:C").Autofit()
    	xlApp.Range("A1").Select()
    	xlapp.DisplayAlerts = .F.
    	xlApp.ActiveWorkbook.SaveAs(newname,-4143) '-4143 is latest supported version
    	xlApp.Workbooks.Close()
    	xlapp.DisplayAlerts = .T.
    	xlApp.Quit()
    	ex_keith = .T.
    END FUNCTION
    Go to the interactive editor and run

    ? ex_keith("C:\keith's sheet.xls","C:\keith's new sheet.xls")

    You should get a .T. result.

    Take a look at the new spreadsheet created in the C:\ root directory

    "C:\keith's new sheet.xls"

    When you get that far we can talk about the changes necessary to address a specific tab.
    There can be only one.

  5. #5
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: Export to Excel Tabs?

    This is fun.

    Got new sheet in root.

    Function works great.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  6. #6
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    OK, now we're cooking!

    If you want to address a specific sheet you use

    XlApp.Sheets("sheetname").Select() 'note quotes

    or

    XlApp.Sheets(sheetnumber).Select() 'note lack of quotes left to right position

    One of these would follow immediately after

    xlApp.Workbooks.Open(excelname)
    There can be only one.

  7. #7
    VAR
    Real Name
    Mike Reed
    Join Date
    Apr 2000
    Location
    Phoenix, AZ
    Posts
    668

    Default Re: Export to Excel Tabs?

    Hi,
    I'm hoping I can tag along...since this has to do with Excel.
    I have a table with data ready for export into an existing Excel worksheet. The Excel worksheet is AZ state mandated worksheet for the first 6 rows and I need to be able to take the data from the table and add it to the worksheet starting at row 7. I have attached the table and the worksheet if you might be able to help. I have searched the help file and tried different SQL commands and DAO commands and I can get close, but I can't get data into the spreadsheet.

    Can you offer any ideas?

    I would appreciate any help or a direction to look to for help.

    Thanks,
    mike
    Mike Reed
    Phoenix, AZ

  8. #8
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    Your version would be...

    Code:
    FUNCTION ex_mike AS L (excelname AS C, newname AS C )
    	ex_mike = .F.
    	Dim xlApp as p
    	dim myCell as c
    	xlApp = ole.create("Excel.Application")
    	xlApp.Workbooks.Open(excelname)
    	'xlApp.Visible = .T. 'comment this line out if you don't want to see Excel
    	tbl = table.open("non_prov")
    	query.filter = ".T."
    	query.order = "recno()"
    	query.options = "I"
    	query.description = "Temporary Query"
    	ix = tbl.query_create()
    	recs = ix.records_get())
    	tbl.fetch_first()
    	start_cell = 7
    	FOR t = 0 TO recs - 1
    		xlApp.Range("A"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.contr_id)
    		xlApp.Range("B"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.regno)
    		xlApp.Range("C"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.called_in)
    		xlApp.Range("D"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.time_called)
    		xlApp.Range("E"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.Nps)
    		xlApp.Range("F"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.sked_beg_time)
    		xlApp.Range("G"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.County)
    		xlApp.Range("H"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.Ps_name)
    		xlApp.Range("I"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.Ps_zip)
    		xlApp.Range("J"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.ahcccsid)
    		xlApp.Range("K"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.Svc)
    		xlApp.Range("L"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.agy_pref_code)
    		xlApp.Range("M"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.mem_pref_code)
    		xlApp.Range("N"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.reason_code)
    		xlApp.Range("O"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.blank)
    		xlApp.Range("P"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.Outcome_code)
    		xlApp.Range("Q"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = tbl.hrs_auth
    		xlApp.Range("R"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = tbl.Hrs_resolve
    		xlApp.Range("S"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.time_len)
    		xlApp.Range("T"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.mem_svc)
    		xlApp.Range("U"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.Mem_timecode)
    		xlApp.Range("V"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.auth_not_code)
    		xlApp.Range("W"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.care_paid_code)
    		xlApp.Range("X"+alltrim(str(start_cell+t))).Select()
    		xlApp.ActiveCell.Formula = alltrim(tbl.comments)
    		tbl.fetch_next()
    	NEXT t
    	'xlApp.Columns("A:X").Autofit()' NOT USED
    	xlApp.Range("A1").Select()
    	xlapp.DisplayAlerts = .F.
    	xlApp.ActiveWorkbook.SaveAs(newname,-4143) '-4143 is latest supported version
    	xlApp.Workbooks.Close()
    	xlapp.DisplayAlerts = .T.
    	xlApp.Quit()
    	ex_mike = .T.
    END FUNCTION
    Usage like

    Code:
    EX_mike("C:\tempdb\Non_provision_master\Non_provision_master.xls","C:\tempdb\Non_provision_master\New Non_provision_master.xls")
    There can be only one.

  9. #9
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    Quote Originally Posted by Stan Mathews View Post
    Create a spreadsheet in your c:\ root directory named keith's sheet.xls.
    Create this function in AlphaSports.
    Keith,

    This line

    FOR t = 0 TO recs

    needs to be

    FOR t = 0 TO recs - 1

    in your function as well.
    There can be only one.

  10. #10
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Smile Re: Export to Excel Tabs?

    Stan,

    What can I say but a great big thank you.

    That is why they call you Stan the Man.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  11. #11
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    Imagine what you can do with that process. I haven't designed a report in years. Nobody wants one. They'd rather have spreadsheets that they can tweak further, dress up, play what if with, etc.

    Glad you like it.

    Generally I do any necessary sorting in the section

    Code:
    query.filter = ".T."
    	query.order = "recno()"
    	query.options = "I"
    	query.description = "Temporary Query"
    if you need to export calculated values not in the actual table you can do things like

    xlApp.Sheets(1).Range("A6").Select
    xlApp.ActiveCell.Formula = "=sum(A2:A4")"
    xlApp.Selection.NumberFormat = "0.00"
    Last edited by Stan Mathews; 03-25-2010 at 04:22 PM.
    There can be only one.

  12. #12
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    One typo in ex_mike

    recs = ix.records_get())

    should be

    recs = ix.records_get()
    There can be only one.

  13. #13
    VAR
    Real Name
    Bill Parker
    Join Date
    Apr 2000
    Location
    Dallas, TX
    Posts
    1,714

    Default Re: Export to Excel Tabs?

    Stan,

    The idea of doing more output directly to Excel is appealing, but I certainly take advantage of multiple grouping levels, etc. that A5 makes pretty easy to use. Some of these reports can get fairly complex, and would seem daunting to render in Excel.

    How much more time do Excel reports require for YOU (not me) vs. A5's report writer. (It would take me way longer than you.)

    Bill.

  14. #14
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    Bill,

    Valid point. My client base (company internal) is obviously different from most developers. As for the multiple grouping levels, I assume you use them to obtain group counts, totals, etc. Most of that can be done using Excel's Data menu, Subtotals which can be coded in the OLE.

    The spreadsheet generation with OLE was time consuming when I first started learning it. Once the basics were mastered (ha!) the finer points seemed easier. Much of the coding is reusable as you can see in comparing ex_keith() and ex_mike().

    Sort of like learning Alpha initially.

    One benefit is the wow factor when you remove the comment mark from the line

    xlApp.Visible = .T. 'comment this line out if you don't want to see Excel

    run the function and show someone that Alpha just created a spreadsheet for them and how. Excel opens, stuff gets put in lots of cells, the spreadsheet is saved, Excel closes. Might be a selling point for someone trying to develop for a current spreadsheet user.
    There can be only one.

  15. #15
    VAR
    Real Name
    Mike Reed
    Join Date
    Apr 2000
    Location
    Phoenix, AZ
    Posts
    668

    Default Re: Export to Excel Tabs?

    Stan,

    Thank you so much! Works like a charm. I'm sure you have spent a lot of time learning/mastering this.

    Thanks for sharing your talent and expertise!

    mike
    Mike Reed
    Phoenix, AZ

  16. #16
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    Glad it works for you. As I mentioned in my reply to Cal, un-comment out the xlApp.Visible = .T. line and run the function if you want a giggle.
    There can be only one.

  17. #17
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: Export to Excel Tabs?

    This is all fun and good.. but it might come as a big surprise to you that you do not need any scripts, no Activex, no OLE, ...nothing at all to do what you want.

    None of the above.

    If curious, I will post an example showing how to export to Excel while maintaining Excel's titles, formatting, and everything else, exporting to one sheet, dozen of sheets .. whatever you want.

  18. #18
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: Export to Excel Tabs?

    Hi Gabe,

    Yes I am curious.

    It will be most interesting to see a working example of your idea?

    Please post your sample as promised for us all to see.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  19. #19
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    Promises, promises.
    There can be only one.

  20. #20
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    Keith,

    Familiar refrain?

    Hi Gabe,

    You wrote on th 12th November
    Quote:
    Keith:
    Sorry about the delay in getting back with you.
    That code involves a trick within a trick within a trick..

    We are still waiting to see this trick of yours.

    The only trick I see you do, and I must say you do it very well, is the vanishing one.

    You must remember, your answers are not just for my benefit but all users of this forum. It is not nice to make promises of showing how to do something and then not keeping to it.

    So, how about that trick within the trick?
    There can be only one.

  21. #21
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    Keith,

    Familiar refrain? (posted on 12-09-2009, 02:25 PM )

    Hi Gabe,

    You wrote on th 12th November
    Quote:
    Keith:
    Sorry about the delay in getting back with you.
    That code involves a trick within a trick within a trick..

    We are still waiting to see this trick of yours.

    The only trick I see you do, and I must say you do it very well, is the vanishing one.

    You must remember, your answers are not just for my benefit but all users of this forum. It is not nice to make promises of showing how to do something and then not keeping to it.

    So, how about that trick within the trick?
    Thus far, no further reaponse.
    There can be only one.

  22. #22
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: Export to Excel Tabs?

    Actually, no example is needed. It's easy as pie.
    There is an interesting little known feature of Excel I discovered by just simply playing around and trying things that you would normally think would not work, but they do.

    In Excel, if you are in say sheet_1 you could make the value of a certain cell equals a cell in an entirely different sheet. That's basic stuff. Everybody knows that. But did you know you can make the value of any cell equal the value of any cell in an entirely different spreadsheet? and did you know that if you update the value of that external spreadsheet, it will update it in the current one?

    Knowing that, now you could export your alpha to any spreadsheet (or if you are so inclined, to a tab in the same Excel book) and simply make the values of the cells in the sheet that has all the fancy formatting equal the cells in that other sheet. In other words, that external sheet will be lurking in the background while your fancy spread sheet shows all the formatting you want all the values where you want them, with no scripts or any work whatsoever.

    No, you don't need to copy one cell at a time. All you need to do is adjust the anchors in the coordinates and do a mass copy and you are done in few seconds.

  23. #23
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    If you are responding to my post, save your keystrokes.
    There can be only one.

  24. #24
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: Export to Excel Tabs?

    Hi Stan,

    Sorry to come back to this, I do have a small problem. (we can leave that on one side for the moment)

    What do I need to change in the function to write to the new Excel extension of "XLSX"
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  25. #25
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    The line

    xlApp.ActiveWorkbook.SaveAs(newname,-4143)

    is supposed to save in whatever the latest excel format. I don't have excel 2007 so I can't test it. If you have that version and it isn't working....

    Open excel and type something in a cell.
    Start recording a macro that does something, doesn't matter what, and then save the spreadsheet while the macro is still recording.
    Stop recording the macro.
    Edit the macro.

    You should see something like

    Code:
    ActiveWorkbook.SaveAs Filename:= _
            "C:\Documents and Settings\Keith\My Documents\Book1.xls", FileFormat:= _
            xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
            , CreateBackup:=False
    Find the Immediate window area at the bottom of the screen and type in

    ? xlNormal

    You should see something like

    Code:
    ? xlNormal
    -4143
    The number you see is what you need to plug into the script in the saveas line.

    If you don't have excel 2007 you can't save as "XLSX".
    Last edited by Stan Mathews; 04-24-2010 at 12:33 PM.
    There can be only one.

  26. #26
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: Export to Excel Tabs?

    Hi Stan,

    Here is the modified code that I'm using.

    I have 2 problems.

    1, The last record gets duplicated in the spreadsheet
    2, I get an error message because of the .Autofit()

    I have uploaded screen shots to show data before and after with error message.

    Your help is appreciated.
    'Date Created: 28-Apr-2010 11:58:13 AM
    'Last Updated: 28-Apr-2010 12:43:58 PM
    'Created By : Keith
    'Updated By : Keith
    FUNCTION export_sales2 AS L (excelname AS C, newname AS C )
    export_sales2 = .F.
    Dim xlApp as p
    dim myCell as c
    xlApp = ole.create("Excel.Application")
    xlApp.Workbooks.Open("keith_sheet")
    XlApp.Sheets("Tab 1").Select()
    xlApp.Visible = .T. 'comment this line out if you don't want to see Excel
    tbl = table.open("new_sales")
    query.filter = ".T."
    query.order = "recno()"
    query.options = "I"
    query.description = "Temporary Query"
    ix = tbl.query_create()
    recs = ix.records_get()
    tbl.fetch_first()
    start_cell = 9
    FOR t = 0 TO recs
    xlApp.Range("A"+alltrim(str(start_cell+t))).Select()
    xlApp.ActiveCell.Formula = alltrim(tbl.sales_rep)
    xlApp.Range("B"+alltrim(str(start_cell+t))).Select()
    xlApp.ActiveCell.Formula = tbl.Total_Invoice_Items__Extension
    'xlApp.Range("C"+alltrim(str(start_cell+t))).Select()
    'xlApp.ActiveCell.Formula = alltrim(tbl.email)
    tbl.fetch_next()
    NEXT t
    tbl.close()
    xlApp.Columns("A:B").Autofit()
    xlApp.Range("A1").Select()
    xlapp.DisplayAlerts = .F.
    xlApp.ActiveWorkbook.SaveAs(newname,-4143) '-4143 is latest supported version
    xlApp.Workbooks.Close()
    xlapp.DisplayAlerts = .T.
    xlApp.Quit()
    ex_keith = .T.
    END FUNCTION
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  27. #27
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    Remember post 9 in this thread? Since we are using

    for 0 to .... instead of starting at 1, we have to decrement the record count by 1. Your script should read

    FOR t = 0 TO recs - 1


    Not sure about the protected worksheet problem. Is it actually protected? Does it need to be? Will the password allways be the same?
    There can be only one.

  28. #28
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: Export to Excel Tabs?

    Hi Stan,

    Thanks for getting back so quickly.

    Unfortunately the FOR t = 0 TO recs - 1 did not make nay difference, I still get the last record duplicated.

    As I was writing this I changed the start_cell to start_cell = 8 and that has eliminated the duplication.

    If I remove the .Autofit() I no longer get the error message but I have to make sure Excel is not open first. I need to experiment to see what happens when I try to add data to another tab on the same spreadsheet.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  29. #29
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    Try changing the xlapp = ole.create() to

    xlApp = ole.getobject("","Excel.Application")

    The OLE.GETOBJECT() method uses an existing OLE automation object, if available. Otherwise, it creates a new one.
    There can be only one.

  30. #30
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Export to Excel Tabs?

    The reason I asked about the protection is that the command to unprotect the sheet, in xbasic, is simply

    xlApp.ActiveSheet.Unprotect()

    I don't see a way to supply the password, if there is one, to the command.
    There can be only one.

Similar Threads

  1. Export to Excel
    By efrierson in forum Alpha Five Version 9 - Desktop Applications
    Replies: 0
    Last Post: 10-20-2009, 01:40 PM
  2. Excel Export
    By steinmanal in forum Alpha Five Version 9 - Desktop Applications
    Replies: 3
    Last Post: 02-19-2009, 02:48 PM
  3. Import excel then export to excel
    By popellis in forum Alpha Five Version 8
    Replies: 4
    Last Post: 04-03-2008, 11:13 PM
  4. Export to Excel
    By Bob Whitaker in forum Alpha Five Version 5
    Replies: 0
    Last Post: 07-14-2005, 12:53 AM
  5. Export to Excel
    By Mike Reed in forum Alpha Five Version 1
    Replies: 3
    Last Post: 07-14-2004, 02:27 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •