+ Reply to Thread
Results 1 to 1 of 1

VBA Function for XFDF import into Excel very slow

Hybrid View

willefg VBA Function for XFDF import... 10-26-2016, 06:28 PM
  1. #1
    Registered User
    Join Date
    11-12-2015
    Location
    Bladel, the Netherlands
    MS-Off Ver
    Office 2016 Pro
    Posts
    4

    VBA Function for XFDF import into Excel very slow

    I found a VBA function that parses Adobe PDF Form XML data (.xfdf) into an Excel worksheet. When this code is used in a separate Workbook without anything else it works fast (<1 sec). However when I use it in the large workbook that I use to generate individual PDF reports it's extremely slow (~5 minutes!!)

    I've tried adding Application.ScreenUpdating = False, Application.EnableEvents = False, Application.Calculation = xlCalculationManual and Application.Volatile (False), but it didn't help.

    Any ideas are very welcome. (I'm a VBA beginner, able to copy and adapt scripts I find for my purposes...)

    This is the code used:

    Formula: copy to clipboard
    Sub ReadXML()

    Call fnReadXMLByTags

    End Sub



    Function fnReadXMLByTags()

    Dim mainWorkBook As Workbook

    Set mainWorkBook = ActiveWorkbook

    bestand = mainWorkBook.Sheets("Blad6").Range("G10").Value

    mainWorkBook.Sheets("Blad6").Range("A:B").Clear

    Set oXMLFile = CreateObject("Microsoft.XMLDOM")

    XMLFileName = bestand

    oXMLFile.Load (XMLFileName)

    Set ValueNodes = oXMLFile.SelectNodes("/xfdf/fields/field/value/text()")

    mainWorkBook.Sheets("Blad6").Range("A1,B1").Interior.ColorIndex = 40

    mainWorkBook.Sheets("Blad6").Range("A1,B1").Borders.Value = 1

    mainWorkBook.Sheets("Blad6").Range("A" & 1).Value = "Vraag"

    mainWorkBook.Sheets("Blad6").Range("B" & 1).Value = "Antwoord"


    For i = 0 To (ValueNodes.Length - 1)

    Antwoord = ValueNodes(i).NodeValue


    'mainWorkBook.Sheets("Blad6").Range("B" & i + 2).Borders.Value = 1

    mainWorkBook.Sheets("Blad6").Range("B" & i + 2).Value = Antwoord

    mainWorkBook.Sheets("Blad6").Range("B" & i + 2).NumberFormat = "#"


    Next

    'Reading the Attributes

    Set Nodes_Attribute = oXMLFile.SelectNodes("/xfdf/fields/field")

    For i = 0 To (Nodes_Attribute.Length - 1)

    Vraag = Nodes_Attribute(i).getAttribute("name")

    'mainWorkBook.Sheets("Blad6").Range("A" & i + 2).Borders.Value = 1

    mainWorkBook.Sheets("Blad6").Range("A" & i + 2).Value = Vraag

    Next

    End Function
    Last edited by willefg; 10-26-2016 at 06:33 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How can I link PDF Form .xfdf data to Excel worksheet
    By willefg in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-19-2016, 12:16 PM
  2. COUNTIFS function makes excel slow, how to make the function "shorter"
    By Gifupack in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-07-2015, 07:01 AM
  3. Import Data from Web to Excel Function
    By luctru in forum Excel General
    Replies: 0
    Last Post: 03-15-2011, 09:32 PM
  4. Import Data From Mdb Very Very Slow...
    By sal21 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-29-2006, 10:26 AM
  5. XML Import too slow
    By detritus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-21-2006, 06:15 AM
  6. Excel 2003 Slow Function Argument Window
    By dgp@dodgeit.com in forum Excel General
    Replies: 2
    Last Post: 06-28-2005, 02:05 PM
  7. Why is the subtotal function in excel 2003 very slow compared to .
    By wd1 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-09-2005, 10:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1