Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

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

Help with word import

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

    Help with word import

    Hello All,

    I have a number of word documents from which I would like to get data to place into a table in Alpha 5. I have looked at the import operations and have even tried to import the document first into excel and then do an import into alpha five. Unfortunately, the number of documents is quite large...in excess of (4) four thousand!. Doing it 'manually' then is really not an option! I know that this can be done in using xbasic, and I have searched the forums for just such help. But I haven't yet become an xbasic 'expert'! (not for want of trying, though!).

    The documents are all laid out in the same way, that is, the data that I want is in the same position on every document and all the documents reside in the same folder on the clients' machine. (See jpg image for an example).

    There exists on the document the clients' header information(not shown in the jpg example) and some other footer text which I don't need.

    If anyone has an idea on what would be the most efficient way to accomplish this task, (and any code or function which might make it possible!) any help would be greatly appreciated!
    Thanks in advance.
    exampleDoc.JPG

    #2
    Re: Help with word import

    Have you considered converting the word files into text files and then parsing them?

    Comment


      #3
      Re: Help with word import

      Originally posted by quad7 View Post
      I have looked at the import operations and have even tried to import the document first into excel and then do an import into alpha five. Unfortunately, the number of documents is quite large...in excess of (4) four thousand!.
      Use the example in ole.create() to convert the documents to excel. (Wrap a loop around the example feeding the document names.) I don't remember the parameter for wordApp.ActiveDocument.SaveAs(NewDoc,0) to save as excel at the moment but you can discover it in the macro editor.

      Then design an import operation, convert it to xbasic. Wrap that script in a loop as above.
      Last edited by Stan Mathews; 08-30-2011, 09:58 AM.
      There can be only one.

      Comment


        #4
        Re: Help with word import

        There doesn't seem to be a way to save a Word doc as Excel. You could save them all as txt (parameter is 2) and then parse them as suggested.
        There can be only one.

        Comment


          #5
          Re: Help with word import

          You should be able to do this very easily with xbasic, except for one step.
          The first step is to save these files as txt. No, you don't have to do that manually. There are many software (I believe some shareware as well) to change a whole batch of files from doc to txt.
          Once you do that, from there it's a snap. You could read these files into alpha table (an UDF is probably appropriate here).
          Here is a snipet of code to read a txt file into an array (you could modify it to read directly into table, or from the array to a table):
          Code:
          dim data (10) as C
          file_pointer = file.open("C:............test.txt", FILE_RW_SHARED)
          Data[1] = file_pointer.read(1000)
          file_pointer.close()
          The reason to read it first into an array is to parse each documents to meaningful data (from, to ...etc) and add each as a field in the table.

          Comment


            #6
            Re: Help with word import

            The real problem that I see is that by automating this process, the potential exits for a number (probably a lot) of documents not to properly align and therefor presenting additional reconciliation issues that are hard to track down. Is the data on the document essentially required or you are simply importing to establish the history of trading? If you are trying to simply create a history, then it may simpler to have a button on the client form that opens a list showing the history. Click on the document you may want to view from the list and open it.
            -----------------------------------------------
            Regards
            Mark Pearson
            [email protected]
            Youtube channel
            Website

            Comment


              #7
              Re: Help with word import

              If the documents have names, why not just build a file list from which you can fire Word and view them?
              The Person Name could be imported from a .TXT document position to create a root record?

              Just noticed, that's what Mark sort of just said. Doh!
              See our Hybrid Option here;
              https://hybridapps.example-software.com/


              Apologies to anyone I haven't managed to upset yet.
              You are held in a queue and I will get to you soon.

              Comment


                #8
                Re: Help with word import

                To everyone who responded... A very big THANK YOU!
                I struggled with and tried your suggestions and was quite amazed at the ease with which I was able to convert Word docs in txt files and even with the parsing of the data!
                Then I saw Mark Pearson's suggestion that I forget about automating this process and just put a button on the form
                for the client to view the historical data.

                Now I am stuck ( with the code that is). I realize that
                1. I want to open a word document based on the "customer Name" on my form "customers".
                2. There may be more than one word document with the customer's name in the folder- so i need to present a 'filtered' list for the user?
                3. The file name for the word document contains the "customerName" somewhere within!
                3. Close the word application from alpha when the user is finished viewing the historical data

                I have looked at filefind.grep(). contents() but I am unsure as to the usage.
                I feel that there MUST be a really simple way to do this..but I am so caught up experimenting with xbasic that I " can't see the forest for the trees"!
                Any help?

                Comment


                  #9
                  Re: Help with word import

                  Attached is a script you can import and try. In my case it open tech documents fro a button click on a form. The very first line gets text from a field on a form. It uses this text to show an xdialog with all the documents that contain that text. It then allows you to select the document and open.

                  Note you will need to edit the lines where it is looking for pdf and change to doc You will slo need to edit lines where it is looking for the path to the documents. In mycase that path has a TDL in it.
                  Attached Files
                  -----------------------------------------------
                  Regards
                  Mark Pearson
                  [email protected]
                  Youtube channel
                  Website

                  Comment


                    #10
                    Re: Help with word import

                    When you were doing your due diligence, you passed over several options to arrive at filefind.grep(). One of those would have been

                    filefind.get()

                    as in

                    list = filefind.get(path + "\*"+customer_name.value+"*", FILE_FIND_NOT_DIRECTORY, "X")

                    assuming that customer_name is the object name of the "customer Name" field on your "customers" form and substituting/establishing the path variable.
                    There can be only one.

                    Comment


                      #11
                      Re: Help with word import

                      Stan,
                      The more I browse these forums, and try to create "meaningful" applications, the more I am humbled by those with so much more experience and "know how" than I.
                      I am ( as I am sure are many others) eternally grateful for the likes of you and Mark and others!

                      Comment


                        #12
                        Re: Help with word import

                        My "experience" is nothing more than having encountered the same issues you face and making enough errors along the way to finally find the way to make some things work. As I indicated, you did your "due diligence". You found the filefind methods. That's so much more than many would have accomplished.

                        I salute your efforts.

                        Reading post #8 a bit further.....

                        3. Close the word application from alpha when the user is finished viewing the historical data
                        (Really point 4, but who's counting)

                        It is likely possible to find the handle/name of the opened word window and close it when Alpha gets focus once more but wouldn't you assume that the user has enough sense to close the document?
                        Last edited by Stan Mathews; 09-03-2011, 06:23 PM.
                        There can be only one.

                        Comment


                          #13
                          Re: Help with word import

                          Thank you Mark for your quick response.
                          This part of my App is the only thing that's keeping me from a rollout to the customer and I do appreciate your help!
                          However, I attached your script to my form after making the changes you suggested.
                          The dialog box comes up and it is empty...so I assume that my 'path' statement is incorrect.
                          My word files reside in G:\worddocs.....so should I replace the two instances of your "TDL" with my path?
                          When I do the list is still empty! when I try that line of code in the interactive, it returns : G:\A5V10MyApplicationG:\worddocs- What am I doing wrong?

                          Comment


                            #14
                            Re: Help with word import

                            Thank Stan for your uplifting comments!
                            Sorry for the numbering snafu!
                            I think it's exhaustion! I've been at it all day!
                            And as for the user having enough sense to close the word document....I assume nothing given the state for the current record keeping system my client currently has in place!
                            So I just wanted to make the application as "idiot proof" as possible!

                            Comment


                              #15
                              Re: Help with word import

                              The issue you have is that path pickups up the path to your db first so change

                              path = a5.get_path() + "\TDL\\" + docpart

                              to

                              path = "G:\worddocs\" + docpart or

                              "G:\worddocs\\" + docpart

                              or better still to gid rid of the \ issues than

                              path = "G:" + chr(92) + "worddocs" + chr(92) + docpart
                              Last edited by Clunes; 09-03-2011, 09:34 PM.
                              -----------------------------------------------
                              Regards
                              Mark Pearson
                              [email protected]
                              Youtube channel
                              Website

                              Comment

                              Working...
                              X