How to export attributes to excel

3537
14
02-15-2011 05:51 AM
DonFreeman
New Contributor
Can someone point me to instructions on how to export a FeatureLayer's attribute table to an excel or CSV file?
Thanks
0 Kudos
14 Replies
DonFreeman
New Contributor
I suggest you leave the apps visible so you can see what is happening. Refer to the sheet by its number and capture the variable.

myvar = ExApp.ActiveWorkbook.Sheet(1).Range("b2").Value   

Then place the variable into your document.

wdApp.ActiveDocument.Bookmarks("LANDKEY").Select
wdApp.Selection.TypeText (Transform(myvar))

Are you successfully getting both applications started? If you can't see them visibly, use task manager to check the processes.
0 Kudos
by Anonymous User
Not applicable
Have you considered using the Open Office SDk For MS Office?

http://msdn.microsoft.com/en-us/library/bb448854.aspx

I've had great success creating Excel and Word docs from Silverlight and Flex Data grids with this.
Essentially you end up creating an xml document which will open in MS office.
0 Kudos
pavankalvala
New Contributor
Hi Don,

I got it finally. Thanks for your help.

Here is the code I got to pull values from excel to word.

Sub createWordReportFrom Excel()
'On Error GoTo errorHandler
Dim wdApp As Word.Application
Dim myDoc As Word.Document
Dim mywdRange As Word.Range
Dim A As Excel.Range
Dim B As Excel.Range

Set wdApp = New Word.Application
With wdApp
.Visible = True
.WindowState = wdWindowStateMaximize
End With

Set myDoc = wdApp.Documents.Add(Template:="C:\projects\FINAL.doc")
Set A = Sheets("Mobile").Range("A2")       Set B = Sheets("Mobile").Range("B2")

With myDoc.Bookmarks
.Item("FID").Range.InsertAfter A        //FID is the bookmark name in word doc
.Item("division").Range.InsertAfter B   //division is the bookmark name in word doc

End With

'errorHandler:
'Set wdApp = Nothing
'Set myDoc = Nothing
'Set mywdRange = Nothing
End Sub


Thanks.
0 Kudos
pavankalvala
New Contributor
Is there a way to populate field values from an identify dialog box to a doc template?

I created a doc template with few bookmarks in it. (Bookmarks are to populate the needed values from a source).

When I select a feature in ArcMap and identify the feature, we get an "identify dialog box" with "field name" to the left and "field values" to the right.

Is there a way to programmatically loop through this identify dialog box and populate field values to a MS word doc template.

Please guide me.
Thanks.
0 Kudos
TroyProctor
New Contributor III
Have you considered using the Open Office SDk For MS Office?

http://msdn.microsoft.com/en-us/library/bb448854.aspx

I've had great success creating Excel and Word docs from Silverlight and Flex Data grids with this.
Essentially you end up creating an xml document which will open in MS office.


Michael,
How were you able to use the Open Office SDK when it's references DocumentFormat.OpenXml, etc. are not Silverlight assemblies?

Thanks for your time,
Troy
0 Kudos