Solved

Can I Get Data from an InfoPath Form Into Excel or Access with VBA?

Posted on 2010-08-25
7
2,803 Views
Last Modified: 2013-11-27
Someone created an InfoPath form which various people e-mail to me to send me information. The problem is, we don't have MOSS, and I can't do anything with the data in the form unless I want to copy and paste each field into either a spreadsheet or a database.

I am hoping there is a way to extract the data from the InfoPath form into Excel or Access using some VBA code.

Does anyone do anything like this?
0
Comment
Question by:Rex85
  • 3
  • 2
  • 2
7 Comments
 
LVL 1

Expert Comment

by:Juice841
ID: 33524357
I assume you are getting the form.xml files back from each submitter.  

If so you can import the form results into Excel by selecting the [Data] tab then selecting [Other Sources]-[From XML  Data Import]

J
0
 

Author Comment

by:Rex85
ID: 33524400
I can export them to Excel yes. I am receiving the Form.xml file.

I was hoping there was a way to code it so that executing a macro from Excel or Access could extract the data from the form into a table in it's proper place.

0
 
LVL 1

Accepted Solution

by:
Juice841 earned 500 total points
ID: 33525655
Here is an example....

1. update the ReadXMLIntoCells sub to match for infopath xml nodes
2. add column headers to your sheet
3. you will need to include a reference in you excel vba for MS XML ([Tools] -[References]

J

Private Sub CommandButton1_Click()
    Dim iCount
    
    'for a max set of rows
    For iCount = 1 To 1000
        
        'If this is an empty row then read a file and import
        If IsEmpty(Cells(iCount, 1)) Then
            ReadXMLIntoCells (iCount)
            Exit For
        End If
        
    Next iCount
    
    
End Sub

Private Sub ReadXMLIntoCells(i)
    Dim doc As MSXML2.DOMDocument30
    Dim mnode As MSXML2.IXMLDOMNode
    Dim sFile
    
    'create xml doc
    Set doc = New MSXML2.DOMDocument30
    
    'get a filename from the user
    sFile = Application.GetOpenFilename("XML Files (*.XML), *.XML", , "Open an xml file...")
    
    'loa the file from the user
    doc.Load (sFile)
    
    'the cells based on node name in infopath...defaults are my:field.....
    Cells(i, 1) = doc.SelectSingleNode("//my:field1").Text
    
    Cells(i, 2) = doc.SelectSingleNode("//my:field2").Text

End Sub

Open in new window

0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 28

Expert Comment

by:clayfox
ID: 33535428
The other option is to have the data stored in a database rather than the indivdual forms.

Then you can connect Excel to the database and all of your records are aggregated.
0
 

Author Comment

by:Rex85
ID: 33535514
I would prefer the aggregated database approach. I am not locked into Excel necessarilly. I am still working with the code Juice841 provided.

Would the code to store the Infopath data in a database (Access perhaps?) be similar?

Rex
0
 
LVL 28

Expert Comment

by:clayfox
ID: 33536635
You can utilize a database without any code, completely codeless.

You would need to redo the form as a database type form (linked to a table). Or get a third party tool like www.qdabra.com provides.
0
 

Author Closing Comment

by:Rex85
ID: 33648685
Thanks.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Before you can digitally sign infopath forms, you must have a digital certificate. Microsoft Certificate Services will need to be enabled on a Windows Server 2008 to facilitate the creation and verification of the digital certifciates on the web ser…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question