• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Extract data in svg file and store automatically in excel

uma_sb

New Member
suppose if there are 20 svg files with the same circuit components but with different component values, I need to extract the content of transistor(model number) in the circuit alone and automatically export them to excel sheet. Kindly help. TIA
 
Uma_sb

Firstly, Welcome to the Chandoo.org Forums

The code below will import all the SVG files in a specified directory into new worksheets in the current Excel file
The worksheets will have the name of the SVG File

You can change the logic to extract only certain data to suit yourself

Code:
Sub Import_SVG_File()
'
' Import SVG Files to worksheets as Text
'
' By: Hui
' July 2017
'

Dim strFilename As String
Dim strFileContent As String
Dim iFile As Integer
Dim MySVGFile() As String

Dim MyFolder As String
Dim MyFile As String

MyFolder = "C:\Users\Huis\Desktop\SVG Files" 'Change as appropriate

MyFile = Dir(MyFolder & "*.svg") 'Select SVG file type

ChDir MyFolder

Do While MyFile <> ""
  'Add new worksheet
  Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = MyFile
  Worksheets(MyFile).Select

  iFile = FreeFile

  'Open SCVG File and load it to an array
  Open MyFile For Input As #iFile
  strFileContent = Input(LOF(iFile), iFile)

  Close #iFile

  'Split array to another array
  MySVGFile = Split(strFileContent, vbLf)

  'Loop through each line of the SVG File
  For i = 1 To UBound(MySVGFile, 1)
  'Debug.Print i, myfile(i)

  'Put logic here to check and extract data
  ActiveSheet.Cells(i, 1) = MySVGFile(i)
  Next i
  
  'goto next file
  MyFile = Dir
Loop

End Sub

Posting a sample file with details of what you require will get a more specific response
 
Back
Top