[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2010-08-25
7
Medium Priority
?
3,216 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 2000 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
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

872 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