Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Export to Excel Tabs?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    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.

    Comment


    • #17
      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.

      Comment


      • #18
        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!

        Comment


        • #19
          Re: Export to Excel Tabs?

          Promises, promises.
          There can be only one.

          Comment


          • #20
            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.

            Comment


            • #21
              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.

              Comment


              • #22
                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.

                Comment


                • #23
                  Re: Export to Excel Tabs?

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

                  Comment


                  • #24
                    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!

                    Comment


                    • #25
                      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, 11:33 AM.
                      There can be only one.

                      Comment


                      • #26
                        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!

                        Comment


                        • #27
                          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.

                          Comment


                          • #28
                            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!

                            Comment


                            • #29
                              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.

                              Comment


                              • #30
                                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.

                                Comment

                                Working...
                                X