Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

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,132 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

610 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