POST
|
I am populating field values from selected features onto a word document bookmark. I need code help in assigning the value to the bookmark range in c#. Here is the code I am currently working with C#. // opening word application wdApp = new Microsoft.Office.Interop.Word.Application(); wdApp.Visible = true; wdApp.WindowState = WdWindowState.wdWindowStateMaximize; // opening the word document from config file wddoc = wdApp.Documents.Add(ConfigurationSettings.AppSettings["WordDocumentPath"]); { var with = wddoc.Bookmarks; with.item("A").Range.InsertAfter(A); // @@@ help here: } } with.item is not acceptable in the c#. getting error at . item. What do I write In order to make it work in C#. Please help.
... View more
06-13-2011
04:26 PM
|
0
|
0
|
428
|
POST
|
I am populating field values from selected features onto a word document bookmark. I need code help in assigning the value to the bookmark range in c#. Here is the code I am currently working with C#. // opening word application wdApp = new Microsoft.Office.Interop.Word.Application(); wdApp.Visible = true; wdApp.WindowState = WdWindowState.wdWindowStateMaximize; // opening the word document from config file wddoc = wdApp.Documents.Add(ConfigurationSettings.AppSettings["WordDocumentPath"]); { var with = wddoc.Bookmarks; with.item("A").Range.InsertAfter(A); // @@@ help here: } } with.item is not acceptable in the c#. getting error at . item. What do I write In order to make it work in C#. Please help.
... View more
06-13-2011
04:24 PM
|
0
|
0
|
221
|
POST
|
I have code below to pull field value from a feature selction onto a word document template. Instead of hard coding the field names, I would like to go through config file. How can this be done. Here is the code below: Public Overrides Sub OnMouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Integer, ByVal Y As Integer) Dim pMxdoc As IMxDocument Dim pActiveView As IActiveView Dim pEnumLayer As IEnumLayer Dim pLayer As ILayer Dim pFlayer As IFeatureLayer Dim pFeatureSelection As IFeatureSelection Dim pSelectionSet As ISelectionSet Dim pEnumFeat As IEnumFeature Dim pEnumFeatSet As IEnumFeatureSetup Dim pFeat As IFeature Dim A As Double Dim B As String Dim B1 As String Dim pFeatSel As IFeatureSelection Dim pMap As IMap Dim pfeatureclass As IFeatureClass Dim fields As IFields Dim C As Long Dim ii As Long Dim Field As IField Dim intFldIndex As Integer Dim fieldname As String Dim fieldvalue As Integer Dim value As String Dim namelist As String Dim wdApp As Microsoft.Office.Interop.Word.Application Dim mydoc As Microsoft.Office.Interop.Word.Document Dim mywdRange As Microsoft.Office.Interop.Word.Range pMxdoc = m_application.Document pActiveView = pMxdoc.FocusMap pMap = pMxdoc.FocusMap pFlayer = pMxdoc.SelectedLayer pfeatureclass = pFlayer.FeatureClass fields = pfeatureclass.Fields pFeatureSelection = pFlayer pSelectionSet = pFeatureSelection.SelectionSet ' Verify that there is at least 1 layer in the TOC If pMap.LayerCount < 1 Then MsgBox("Must have at least 1 layer in your map.") Exit Sub End If ' verify the name of the selected layer Dim count As Integer count = pSelectionSet.Count If pSelectionSet.Count <> 0 Then MsgBox("You have have selected: " & pFlayer.Name) End If ' get the field count C = fields.FieldCount MsgBox("There are: " & C & "fields in this layer") pEnumFeat = pMxdoc.FocusMap.FeatureSelection 'pFeat = pEnumFeat.Next pEnumFeatSet = pEnumFeat pEnumFeatSet.AllFields = True pFeat = pEnumFeat.Next ' loop through each field and add the field name to a list For ii = 0 To fields.FieldCount - 1 Field = fields.Field(ii) fieldname = Field.Name ' this gives the field name value = pFeat.Value(ii).ToString ' this gives the field value namelist = namelist & fieldname & value & Chr(13) Next ' diaplay the list of field names in a messagebox MsgBox(namelist, , "field names and value") ' loop through to get value of FID Do While (Not pFeat Is Nothing) A = pFeat.Value(pFeat.Fields.FindField("UFO_ID")) // @@@@ want to get this through config file B = pFeat.Value(pFeat.Fields.FindField("DATECREATE")) pFeat = pEnumFeat.Next 'MsgBox(A) Loop ' opening word doc with the field values inside the word bookmarks wdApp = New Microsoft.Office.Interop.Word.Application With wdApp .Visible = True .WindowState = WdWindowState.wdWindowStateMaximize End With mydoc = wdApp.Documents.Add(Template:="C:\Documents and Settings\ZQ3079\Mobile project\ExportWord(VB)\Audit Form Final.doc") With mydoc.Bookmarks .Item("A").Range.InsertAfter(A) ' "A" is bookmark name in word document .Item("C").Range.InsertAfter(B) ' "C" is bookmark name in word document End With End Sub Let me know.
... View more
06-09-2011
07:05 PM
|
0
|
0
|
65
|
POST
|
I have code below to pull field value from a feature selection onto a word document template. Upon feature selection, the code below will loop through each field and I can pull the field value based of hard coding the field name. Instead of hard coding the field names, I would like to go through config file, where I can set the field names in config file like adding a key = FID and retrieve the value. All I am doing is to read the field value from config file than hard coding. How can this be done? Please help me. Here is the code below by hard coding the field name: Public Overrides Sub OnMouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Integer, ByVal Y As Integer) Dim pMxdoc As IMxDocument Dim pActiveView As IActiveView Dim pEnumLayer As IEnumLayer Dim pLayer As ILayer Dim pFlayer As IFeatureLayer Dim pFeatureSelection As IFeatureSelection Dim pSelectionSet As ISelectionSet Dim pEnumFeat As IEnumFeature Dim pEnumFeatSet As IEnumFeatureSetup Dim pFeat As IFeature Dim A As Double Dim B As String Dim B1 As String Dim pFeatSel As IFeatureSelection Dim pMap As IMap Dim pfeatureclass As IFeatureClass Dim fields As IFields Dim C As Long Dim ii As Long Dim Field As IField Dim intFldIndex As Integer Dim fieldname As String Dim fieldvalue As Integer Dim value As String Dim namelist As String Dim wdApp As Microsoft.Office.Interop.Word.Application Dim mydoc As Microsoft.Office.Interop.Word.Document Dim mywdRange As Microsoft.Office.Interop.Word.Range pMxdoc = m_application.Document pActiveView = pMxdoc.FocusMap pMap = pMxdoc.FocusMap pFlayer = pMxdoc.SelectedLayer pfeatureclass = pFlayer.FeatureClass fields = pfeatureclass.Fields pFeatureSelection = pFlayer pSelectionSet = pFeatureSelection.SelectionSet ' Verify that there is at least 1 layer in the TOC If pMap.LayerCount < 1 Then MsgBox("Must have at least 1 layer in your map.") Exit Sub End If ' verify the name of the selected layer Dim count As Integer count = pSelectionSet.Count If pSelectionSet.Count <> 0 Then MsgBox("You have have selected: " & pFlayer.Name) End If ' get the field count C = fields.FieldCount MsgBox("There are: " & C & "fields in this layer") pEnumFeat = pMxdoc.FocusMap.FeatureSelection 'pFeat = pEnumFeat.Next pEnumFeatSet = pEnumFeat pEnumFeatSet.AllFields = True pFeat = pEnumFeat.Next ' loop through each field and add the field name to a list For ii = 0 To fields.FieldCount - 1 Field = fields.Field(ii) fieldname = Field.Name ' this gives the field name value = pFeat.Value(ii).ToString ' this gives the field value namelist = namelist & fieldname & value & Chr(13) Next ' diaplay the list of field names in a messagebox MsgBox(namelist, , "field names and value") ' loop through to get value of FID //@@@@@ I need help here @@@@@@@ Do While (Not pFeat Is Nothing) A = pFeat.Value(pFeat.Fields.FindField("UFO_ID")) // @@@@ want to set this in config file B = pFeat.Value(pFeat.Fields.FindField("DATECREATE")) pFeat = pEnumFeat.Next 'MsgBox(A) Loop ' opening word doc with the field values inside the word bookmarks wdApp = New Microsoft.Office.Interop.Word.Application With wdApp .Visible = True .WindowState = WdWindowState.wdWindowStateMaximize End With mydoc = wdApp.Documents.Add(Template:="C:\Documents and Settings\ZQ3079\Mobile project\ExportWord(VB)\Audit Form Final.doc") With mydoc.Bookmarks .Item("A").Range.InsertAfter(A) ' "A" is bookmark name in word document .Item("C").Range.InsertAfter(B) ' "C" is bookmark name in word document End With End Sub Let me know.
... View more
06-09-2011
07:00 PM
|
0
|
0
|
554
|
POST
|
I have code below to pull field value from a feature selction onto a word document template. Instead of hard coding the field names, I would like to go through config file. How can this be done. Here is the code below: Public Overrides Sub OnMouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Integer, ByVal Y As Integer) Dim pMxdoc As IMxDocument Dim pActiveView As IActiveView Dim pEnumLayer As IEnumLayer Dim pLayer As ILayer Dim pFlayer As IFeatureLayer Dim pFeatureSelection As IFeatureSelection Dim pSelectionSet As ISelectionSet Dim pEnumFeat As IEnumFeature Dim pEnumFeatSet As IEnumFeatureSetup Dim pFeat As IFeature Dim A As Double Dim B As String Dim B1 As String Dim pFeatSel As IFeatureSelection Dim pMap As IMap Dim pfeatureclass As IFeatureClass Dim fields As IFields Dim C As Long Dim ii As Long Dim Field As IField Dim intFldIndex As Integer Dim fieldname As String Dim fieldvalue As Integer Dim value As String Dim namelist As String Dim wdApp As Microsoft.Office.Interop.Word.Application Dim mydoc As Microsoft.Office.Interop.Word.Document Dim mywdRange As Microsoft.Office.Interop.Word.Range pMxdoc = m_application.Document pActiveView = pMxdoc.FocusMap pMap = pMxdoc.FocusMap pFlayer = pMxdoc.SelectedLayer pfeatureclass = pFlayer.FeatureClass fields = pfeatureclass.Fields pFeatureSelection = pFlayer pSelectionSet = pFeatureSelection.SelectionSet ' Verify that there is at least 1 layer in the TOC If pMap.LayerCount < 1 Then MsgBox("Must have at least 1 layer in your map.") Exit Sub End If ' verify the name of the selected layer Dim count As Integer count = pSelectionSet.Count If pSelectionSet.Count <> 0 Then MsgBox("You have have selected: " & pFlayer.Name) End If ' get the field count C = fields.FieldCount MsgBox("There are: " & C & "fields in this layer") pEnumFeat = pMxdoc.FocusMap.FeatureSelection 'pFeat = pEnumFeat.Next pEnumFeatSet = pEnumFeat pEnumFeatSet.AllFields = True pFeat = pEnumFeat.Next ' loop through each field and add the field name to a list For ii = 0 To fields.FieldCount - 1 Field = fields.Field(ii) fieldname = Field.Name ' this gives the field name value = pFeat.Value(ii).ToString ' this gives the field value namelist = namelist & fieldname & value & Chr(13) Next ' diaplay the list of field names in a messagebox MsgBox(namelist, , "field names and value") ' loop through to get value of FID Do While (Not pFeat Is Nothing) A = pFeat.Value(pFeat.Fields.FindField("UFO_ID")) // @@@@ want to get this through config file B = pFeat.Value(pFeat.Fields.FindField("DATECREATE")) pFeat = pEnumFeat.Next 'MsgBox(A) Loop ' opening word doc with the field values inside the word bookmarks wdApp = New Microsoft.Office.Interop.Word.Application With wdApp .Visible = True .WindowState = WdWindowState.wdWindowStateMaximize End With mydoc = wdApp.Documents.Add(Template:="C:\Documents and Settings\ZQ3079\Mobile project\ExportWord(VB)\Audit Form Final.doc") With mydoc.Bookmarks .Item("A").Range.InsertAfter(A) ' "A" is bookmark name in word document .Item("C").Range.InsertAfter(B) ' "C" is bookmark name in word document End With End Sub Let me know.
... View more
06-08-2011
03:45 PM
|
0
|
0
|
342
|
POST
|
I have code below to pull field value from a feature selction onto a word document template. Instead of hard coding the field names, I would like to go through config file. How can this be done. Here is the code below: Public Overrides Sub OnMouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Integer, ByVal Y As Integer) Dim pMxdoc As IMxDocument Dim pActiveView As IActiveView Dim pEnumLayer As IEnumLayer Dim pLayer As ILayer Dim pFlayer As IFeatureLayer Dim pFeatureSelection As IFeatureSelection Dim pSelectionSet As ISelectionSet Dim pEnumFeat As IEnumFeature Dim pEnumFeatSet As IEnumFeatureSetup Dim pFeat As IFeature Dim A As Double Dim B As String Dim B1 As String Dim pFeatSel As IFeatureSelection Dim pMap As IMap Dim pfeatureclass As IFeatureClass Dim fields As IFields Dim C As Long Dim ii As Long Dim Field As IField Dim intFldIndex As Integer Dim fieldname As String Dim fieldvalue As Integer Dim value As String Dim namelist As String Dim wdApp As Microsoft.Office.Interop.Word.Application Dim mydoc As Microsoft.Office.Interop.Word.Document Dim mywdRange As Microsoft.Office.Interop.Word.Range pMxdoc = m_application.Document pActiveView = pMxdoc.FocusMap pMap = pMxdoc.FocusMap pFlayer = pMxdoc.SelectedLayer pfeatureclass = pFlayer.FeatureClass fields = pfeatureclass.Fields pFeatureSelection = pFlayer pSelectionSet = pFeatureSelection.SelectionSet ' Verify that there is at least 1 layer in the TOC If pMap.LayerCount < 1 Then MsgBox("Must have at least 1 layer in your map.") Exit Sub End If ' verify the name of the selected layer Dim count As Integer count = pSelectionSet.Count If pSelectionSet.Count <> 0 Then MsgBox("You have have selected: " & pFlayer.Name) End If ' get the field count C = fields.FieldCount MsgBox("There are: " & C & "fields in this layer") pEnumFeat = pMxdoc.FocusMap.FeatureSelection 'pFeat = pEnumFeat.Next pEnumFeatSet = pEnumFeat pEnumFeatSet.AllFields = True pFeat = pEnumFeat.Next ' loop through each field and add the field name to a list For ii = 0 To fields.FieldCount - 1 Field = fields.Field(ii) fieldname = Field.Name ' this gives the field name value = pFeat.Value(ii).ToString ' this gives the field value namelist = namelist & fieldname & value & Chr(13) Next ' diaplay the list of field names in a messagebox MsgBox(namelist, , "field names and value") ' loop through to get value of FID Do While (Not pFeat Is Nothing) A = pFeat.Value(pFeat.Fields.FindField("UFO_ID")) // @@@@ want to get this through config file B = pFeat.Value(pFeat.Fields.FindField("DATECREATE")) pFeat = pEnumFeat.Next 'MsgBox(A) Loop ' opening word doc with the field values inside the word bookmarks wdApp = New Microsoft.Office.Interop.Word.Application With wdApp .Visible = True .WindowState = WdWindowState.wdWindowStateMaximize End With mydoc = wdApp.Documents.Add(Template:="C:\Documents and Settings\ZQ3079\Mobile project\ExportWord(VB)\Audit Form Final.doc") With mydoc.Bookmarks .Item("A").Range.InsertAfter(A) ' "A" is bookmark name in word document .Item("C").Range.InsertAfter(B) ' "C" is bookmark name in word document End With End Sub Let me know.
... View more
06-08-2011
03:44 PM
|
0
|
0
|
221
|
POST
|
Here is the full code: (upon selecting a feature, it should display field name and field values) Public Overrides Sub OnMouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Integer, ByVal Y As Integer) Dim pMxdoc As IMxDocument Dim pActiveView As IActiveView Dim pEnumLayer As IEnumLayer Dim pLayer As ILayer Dim pFlayer As IFeatureLayer Dim pFeatureSelection As IFeatureSelection Dim pSelectionSet As ISelectionSet Dim pEnumFeat As IEnumFeature Dim pFeat As IFeature Dim MC As Double Dim pFeatSel As IFeatureSelection Dim pMap As IMap Dim pfeatureclass As IFeatureClass Dim fields As IFields Dim C As Long Dim ii As Long Dim Field As IField Dim intFldIndex As Integer Dim fieldname As String Dim fieldvalue As Integer Dim value As Long // should it be different (string/integer/double or what?) Dim a As Integer Dim namelist As String pMxdoc = m_application.Document pActiveView = pMxdoc.FocusMap pMap = pMxdoc.FocusMap pFlayer = pMxdoc.SelectedLayer pfeatureclass = pFlayer.FeatureClass fields = pfeatureclass.Fields pFeatureSelection = pFlayer pSelectionSet = pFeatureSelection.SelectionSet ' verify the name of the selected layer Dim count As Integer count = pSelectionSet.Count If pSelectionSet.Count <> 0 Then MsgBox("You have have selected: " & pFlayer.Name) End If ' get the field count C = fields.FieldCount MsgBox("There are: " & C & "fields in this layer") pEnumFeat = pMxdoc.FocusMap.FeatureSelection pFeat = pEnumFeat.Next ' loop through each field and add the field name to a list For ii = 0 To fields.FieldCount - 1 Field = fields.Field(ii) fieldname = Field.Name fieldvalue = Field.VarType value = pFeat.Value(ii) // having trouble in getting the value namelist = namelist & fieldname & value & Chr(13) Next ' diaplay the list of field names in a messagebox MsgBox(namelist, , "field names") ' loop to get the field value 'For a = 0 To pFeat.Fields.FieldCount - 1 ' value = pFeat.Value(a) ' namelist = namelist & value & Chr(13) 'Next 'MsgBox(namelist, , "field value") End Sub
... View more
05-17-2011
01:07 PM
|
0
|
0
|
221
|
POST
|
I tried that, but I get an error ' conversion from type '_ComObject' to type 'Long' is not valid' I set the value as : Dim value as long. ( I tried using 'string', 'double', 'long' and I get the same error as above) Any hint?
... View more
05-17-2011
12:37 PM
|
0
|
0
|
1011
|
POST
|
I am able to get the field name through the loop as below: pEnumFeat = pMxdoc.FocusMap.FeatureSelection pFeat = pEnumFeat.Next ' loop through each field and add the field name to a list For ii = 0 To fields.FieldCount - 1 Field = fields.Field(ii) fieldname = Field.Name fieldvalue = Field.VarType ' fieldvalue = pFeat.Value(pFeat.Fields.Field) '' trying to get the field value 'value = Field.DefaultValue '' trying to get the field value namelist = namelist & fieldname & fieldvalue & Chr(13) Next MsgBox(namelist, , "field names") This displays all the fields from the selected feature. How do I get the field value from the above loop.
... View more
05-17-2011
12:14 PM
|
0
|
0
|
1011
|
POST
|
Is there a code to loop through the field names from a selected feature?
... View more
05-17-2011
09:14 AM
|
0
|
0
|
1010
|
POST
|
I am able to get the value of a field name "FID" in a message box. I am trying to put this value into a word doc Bookmark. How can I do this. Any help. Code I used to get the field value of "FID": M = pFeat.Value(pFeat.Fields.FindField("FID")) pFeat = pEnumFeat.Next MsgBox(M) /// I need this value shown in message box pulled into a word doc bookmark.
... View more
05-17-2011
09:14 AM
|
0
|
0
|
1010
|
POST
|
Hi, I am trying to loop through the field names and get field values when a feature is identified. Is there a way to programamtically loop through the field names from an identify wdialog and popultae the field values in a word document. I created a doc template with few bookmarks, so that I can popultae these field values to the bookmark in Word doc. Please help me.
... View more
05-17-2011
08:56 AM
|
0
|
0
|
428
|
POST
|
Is there a way to populate field values from an identify dialog box or upon feature selection 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.
... View more
05-17-2011
08:48 AM
|
0
|
2
|
481
|
POST
|
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.
... View more
05-16-2011
04:58 PM
|
0
|
1
|
549
|
POST
|
Hello, I am a newbie to ArcObjects programming and I've been trying to return a list of field names and field values from a feature when identified. Is there a way to programmatically loop through and get the field values from an identified feature? Please help.
... View more
05-16-2011
03:27 PM
|
0
|
0
|
342
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|