Results 1 to 10 of 10
  1. #1
    PeteL
    Guest

    Data only for forms

    I created a form in Word 2000 and want to use the information in a database. An Excel spreadsheet would do fine. I selected the option to "Save data only for forms", but this creates an individual text file for each document filled in (hardly a useful database). Am I missing something? How can I get this data saved into the spreadsheet?

  2. #2
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Data only for forms

    Peter,

    I don't think you can get around that without having to do some VBA programming.

    Probably you would need something like an Export button (or attached to a FIleSave).

    The easiest way would be to export to the end of a text file, which you then opened in Excel.

    You export code (it's very rough here, just to give a flavour) might be something like:


    dim strOutpout as string
    strOutput = activedocument.formfields("Text1") & vbtab & _
    activedocument.formfields("Text2") & ...

    dim iFileNo as integer
    iFileNo = Freefile
    Open "c:Exceldataoutput.txt" For Append As iFileNo
    print #ifileno, stroutput
    close #ifileno

    Just a starting point. You can write to an excel spreadsheet but that gets more complex

    Geoff
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  3. #3
    5 Star Lounger
    Join Date
    Dec 2000
    Location
    Tallahassee, Florida, USA
    Posts
    901
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Data only for forms

    Another option, check out Access. You can get the spreadsheet functionality and a form interface.
    Karen

  4. #4
    PeteL
    Guest

    Re: Data only for forms

    I was afraid of that. I'll play with it. In the meantime, what do I do with the hundred or so individual text files already created with each saved form? I imagine some sort of loop that reads each text file and appends the data to a single text file. What's the most efficient way to do that? Thanks.

  5. #5
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Data only for forms

    Pete,

    Don't be too afraid. There's a big learning curve to start off with- but onve you start to learn, there's heaps of benefit you can get.

    Are you at all familiar with anything to do with VBA?

    If you are, go into the VBA editor (Alt + F11), type "dir" and press PF1. Read it, and click on the "Example" button.

    That should be enough to show you all the "txt" files in your directory.

    That's a heavy intro- and you need a lot of patience to learn like that. But I think you will learn more that way than having all the code given.

    If you can master the directory command, and know which files to open, I can give you a hand on what to do with them.

    Of course, if you get stuck, there's always someone here to help. But I'd suggest a self start first.

    Just my thoughts- of course, if someone else wants to give you a short cut, that's fine
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  6. #6
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    To import all files into one

    The following code will insert all files of specific type(s) into one word file. You can then save that file into Excel or Access

    You will need to replace the BrowseFolder function with the directory string that contains your files. I use another function there to browse to the directory I want to select.

    <pre>Sub InsertTextFiles()
    'Macro by Andrew Lockton - Chrysalis Design P/L
    'Searchs for files after asking user to select a directory,
    'file type and whether to search nested directories and imports all
    'occurrences of that file type.
    Dim i As Integer
    Dim sfiletype As String
    Dim sDirName As String
    Dim bNested As Boolean
    Dim iResponse

    'Obtain a directory to look in
    sDirName = BrowseFolder("Select the Folder containing the files to be listed?")
    'Which file type do you want listed
    sfiletype = InputBox("What file types do you want? Only Choose Text Types", "File Types", "*.txt")
    'Do you want to include files in subfolders as well
    iResponse = MsgBox("Do you want the files in subfolders too?", _
    vbYesNoCancel, "Subfolders")
    If iResponse = vbYes Then bNested = True
    If iResponse = vbNo Then bNested = False
    If iResponse = vbCancel Then Exit Sub

    With Application.FileSearch
    .LookIn = sDirName
    .FileName = sfiletype
    .SearchSubFolders = bNested
    .Execute

    If .FoundFiles.Count > 0 Then
    'Documents.Add 'Unrem if you need this in a new document
    For i = 1 To .FoundFiles.Count
    Selection.Collapse Direction:=wdCollapseEnd
    Selection.InsertFile FileName:=.FoundFiles(i), Range:="", ConfirmConversions:= _
    False, Link:=False, Attachment:=False
    Selection.TypeParagraph
    Next i
    End If
    End With

    End Sub</pre>

    Andrew Lockton, Chrysalis Design, Melbourne Australia

  7. #7
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: To import all files into one

    I am using Word XP SP3 and am having an issue with "BrowseFolder". When I try to step through the code I receive an error message: compile error-Sub or Function not defined.

    Thanks,
    John

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: To import all files into one

    As Andrew wrote:
    <hr>You will need to replace the BrowseFolder function with the directory string that contains your files<hr>
    So change the line

    sDirName = BrowseFolder("Select the Folder containing the files to be listed?")

    to something like

    sDirName = "C:MyFolder"

    where C:MyFolder is the folder containing the files.

  9. #9
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: To import all files into one

    Hans,

    Thanks, I did not catch that part. I thought that there was some type of function named "BrowserFolder".

    John

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: To import all files into one

    There is, but it's not a standard Word function. That's why Andrew added that remark.

Posting Permissions

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