Académique Documents
Professionnel Documents
Culture Documents
'This code written in VBA accepts an ecxel sheet having coordinates of points in
POI_X, and POI_Y columns.
'Converts the excel sheet to Text file and export to shapefile after converting
the text file to layer.
'So it can also be used to convert text file to shapefile.
' Tools-->References-->MicrosoftExcel 11.0 object Library has to be added so tha
t it can work with excel.
Dim Filename As String 'Contain file name with path
Dim wkb As Workbook
Excel.Application.DisplayAlerts = False
'Opens a dialog file to select
filex = Excel.Application.GetOpenFilename(FileFilter:="microsoft excel files (*.
xls), *.xls", Title:="Please select a file", MultiSelect:=False)
If filex <> False Then
Excel.Application.Workbooks.Open filex
Set wkb = ActiveWorkbook
Dim sPath As String
sPath = wkb.Path ' Getting the path to excel file which is workspace path.
'MsgBox sPath 'Debugging purpose
Filename = GetFileName(CStr(filex)) 'Gets only the file name without extension
wkb.SaveAs Filename:=Filename, FileFormat:=xlText, CreateBackup:=False 'Saves th
e file in Text Format
ActiveWorkbook.Close savechanges:=False
Excel.Application.DisplayAlerts = True
End If
Dim TxtFileName As String
TxtFileName = Filename + ".txt"
End Sub