<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Codejock Developer Community : Copy To ClipBoard</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Report Control : Copy To ClipBoard]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Fri, 15 May 2026 00:50:59 +0000</pubDate>
  <lastBuildDate>Mon, 09 Aug 2010 03:11:55 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.04</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>forum.codejock.com/RSS_post_feed.asp?TID=17020</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Codejock Developer Community]]></title>
   <url>http://forum.codejock.com/forum_images/codejock-logo.gif</url>
   <link>http://forum.codejock.com/</link>
  </image>
  <item>
   <title><![CDATA[Copy To ClipBoard : Hi Shan,   Glad you got it sorted...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17020&amp;PID=59691&amp;title=copy-to-clipboard#59691</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2960">Xander75</a><br /><strong>Subject:</strong> 17020<br /><strong>Posted:</strong> 09 August 2010 at 3:11am<br /><br />Hi Shan, <DIV>&nbsp;</DIV><DIV>Glad you got it sorted out on your own, I have attached the code I created to export either all rows or the selected rows&nbsp;from a ReportControl and format the cells accordingly. </DIV><DIV>&nbsp;</DIV><DIV><FONT color=#ff0000>Please Note:</FONT> I opted out of using the Copy function of the ReportControl as this only copies selected rows, instead I use the record of each row to do what I need to do to copy and format&nbsp;all or&nbsp;only the selected rows. This means I don't have to set&nbsp;each row individually to be selected&nbsp;then remove the selection as your code suggests. This then allows a users selected rows not to be removed by the code "ReportControl.SelectedRows.DeleteAll".</DIV><DIV>&nbsp;</DIV><DIV><FONT color=#000099>Public Sub</FONT> ExportToExcel(rpc <FONT color=#000099>As </FONT>ReportControl, Optional ExportOnlySelected As Boolean = False)<BR>&nbsp;&nbsp;&nbsp; <FONT color=#000099>Dim </FONT>Record <FONT color=#000099>As </FONT>ReportRecord<BR>&nbsp;&nbsp;&nbsp; <FONT color=#000099>Dim </FONT>xlsApp <FONT color=#000099>As </FONT>Excel.Application<BR>&nbsp;&nbsp;&nbsp; <FONT color=#000099>Dim </FONT>xlsWSheet <FONT color=#000099>As </FONT>Excel.Worksheet<BR>&nbsp;&nbsp;&nbsp; <FONT color=#000099>Dim </FONT>i <FONT color=#000099>As Long</FONT>, j <FONT color=#000099>As </FONT><FONT color=#000099>Long</FONT><FONT color=#000000>, x <FONT color=#000099>As Long</FONT><BR></FONT>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp; <FONT color=#006633>' Get or Create Excel Object<BR></FONT>&nbsp;&nbsp;&nbsp; <FONT color=#000099>On Error Resume Next</FONT><BR>&nbsp;&nbsp;&nbsp; <FONT color=#000099>Set </FONT>xlsApp = GetObject(, "Excel.Application")</DIV><DIV>&nbsp;&nbsp;&nbsp; <FONT color=#000099>If </FONT>Err.Number &lt;&gt; 0 <FONT color=#000099>Then</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Set </FONT>xlsApp = <FONT color=#000099>New </FONT>Excel.Application<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Err.Clear<BR>&nbsp;&nbsp;&nbsp; <FONT color=#000099>End If<BR></FONT>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;<FONT color=#006633> </FONT><FONT color=#006600>' Create the WorkSheet</FONT><BR>&nbsp;&nbsp;&nbsp; <FONT color=#000099>Set </FONT>xlsWSheet = xlsApp.Workbooks.Add.ActiveSheet<BR>&nbsp;&nbsp;&nbsp;&nbsp;</DIV><DIV>&nbsp;&nbsp;&nbsp; <FONT color=#000099>With&nbsp;</FONT>xlsWSheet&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#006633>' Export Data from the ReportControl</FONT></DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>If </FONT>ExportOnlySelected <FONT color=#000099>Then</FONT></DIV><FONT color=#006633></FONT><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x = 1</DIV><DIV>&nbsp;</DIV><DIV><DIV><FONT color=#000099><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>For </FONT>i = 0 <FONT color=#000099>To </FONT>rpc.Records.Count - 1</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>If </FONT>rpc.Rows(i).Selected <FONT color=#000099>Then</FONT></DIV><DIV><FONT color=#000099>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color=#000000> x = x + 1</FONT></DIV><DIV>&nbsp;</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Set </FONT>Record = rpc.Records.Record(i)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>For </FONT>j = 1 <FONT color=#000099>To </FONT>rpc.Columns.Count&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Cells(x, j) = Record.Item(j - 1).Value</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#006633>' Format the Cell,&nbsp;formats are&nbsp;Date, Number&nbsp;&amp; Text</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Select Case</FONT> IsNumeric(Record.Item(j - 1).Value)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Case</FONT> <FONT color=#000099>False</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Select Case</FONT> IsDate(Record.Item(j - 1).Value)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Case</FONT> <FONT color=#000099>False</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Cells(x, j).NumberFormat = "@"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Case</FONT> <FONT color=#000099>True</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Cells(x, j).NumberFormat = "dd/mm/yyyy"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>End Select</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Case</FONT> <FONT color=#000099>True</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Cells(x, j).NumberFormat = "#,##0"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>End Select</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Next&nbsp;</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Next&nbsp;</FONT></DIV><DIV><FONT color=#000099>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Else</FONT></DIV></DIV><DIV><FONT color=#000099><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>For </FONT>i = 0 <FONT color=#000099>To </FONT>rpc.Records.Count - 1</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Set </FONT>Record = rpc.Records.Record(i)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>For </FONT>j = 1 <FONT color=#000099>To </FONT>rpc.Columns.Count&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Cells(i + 2, j) = Record.Item(j - 1).Value</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#006633>' Format the Cell,&nbsp;formats are&nbsp;Date, Number&nbsp;&amp; Text</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Select Case</FONT> IsNumeric(Record.Item(j - 1).Value)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Case</FONT> <FONT color=#000099>False</FONT><BR><FONT color=#000099>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select Case</FONT> IsDate(Record.Item(j - 1).Value)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT color=#000099>Case</FONT> <FONT color=#000099>False</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Cells(i + 2, j).NumberFormat = "@"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT color=#000099>Case</FONT> <FONT color=#000099>True</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Cells(i + 2, j).NumberFormat = "dd/mm/yyyy"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT color=#000099>End Select</FONT></DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Case</FONT> <FONT color=#000099>True</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Cells(i + 2, j).NumberFormat = "#,##0"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>End Select</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Next&nbsp;</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Next&nbsp;</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>End If</FONT></DIV><DIV>&nbsp;</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#006633>' Format the Columns</FONT></DIV><DIV><FONT color=#006633>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color=#000000>&nbsp;&nbsp;&nbsp; </FONT><FONT color=#000099>For </FONT>i = 0 <FONT color=#000099>To </FONT>rpc.Columns.Count - 1</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#006633>' Export ColumnHeaders &amp; set as bold</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Cells(1, i + 1) = rpc.Columns(i).Caption</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Cells(1, i + 1).Font.Bold = <FONT color=#000099>True</FONT></DIV><DIV>&nbsp;</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#006633>' Autofit column headers</FONT></DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Columns(i).AutoFit</DIV><DIV>&nbsp;</DIV><DIV><FONT color=#006633><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>' Format the Column Alignments</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Select Case</FONT> rpc.Columns.Column(i).Alignment<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Case</FONT> xtpAlignmentCenter<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Columns(i + 1).HorizontalAlignment = xlCenter<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Case</FONT> xtpAlignmentRight<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Columns(i + 1).HorizontalAlignment = xlRight<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Case</FONT> <FONT color=#000099>Else</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Columns(i + 1).HorizontalAlignment = xlLeft<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>End Select</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000099>Next&nbsp;</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#006633>' Move to first cell to unselect</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Range("A1").Select<BR>&nbsp;&nbsp;&nbsp; <FONT color=#000099>End With</FONT></DIV><DIV><BR>&nbsp;&nbsp;&nbsp; <FONT color=#006633>' Show the Excel Window</FONT><BR>&nbsp;&nbsp;&nbsp; <FONT color=#000099>With </FONT>xlsApp<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .ActiveWindow.SplitRow = 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Visible = <FONT color=#000099>True</FONT><BR>&nbsp;&nbsp;&nbsp; <FONT color=#000099>End With</FONT></DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp; <FONT color=#000099>Set </FONT>xlsApp = <FONT color=#000099>Nothing</FONT><BR>&nbsp;&nbsp;&nbsp; <FONT color=#000099>Set </FONT>xlsWSheet = <FONT color=#000099>Nothing</FONT><BR><FONT color=#000099>End Sub</FONT></DIV><DIV>&nbsp;</DIV><DIV>-------------------------------------------------------------------------------------------------------------</DIV><DIV><FONT color=#006633>' To Call the function if placed inside a Module</FONT></DIV><DIV><FONT color=#000000>Again like yours to call the function use the following if placed in a module:</FONT></DIV><DIV>&nbsp;</DIV><DIV><FONT color=#000099>&nbsp;&nbsp;&nbsp; Call </FONT>ExportToExcel(Me.Reportcontrol) </DIV><DIV>&nbsp;</DIV><DIV>Or to export only the selected rows:</DIV><DIV>&nbsp;</DIV><DIV><FONT color=#000099>&nbsp;&nbsp;&nbsp; Call </FONT>ExportToExcel(Me.Reportcontrol, <FONT color=#000099>True</FONT>)</DIV><DIV>&nbsp;</DIV><DIV>-------------------------------------------------------------------------------------------------------------</DIV><DIV><FONT color=#006633>' To Call the function if&nbsp;placed inside a Class</FONT></DIV><DIV>If you put it into a class as I have lets say called "Functions" then use the following:</DIV><DIV>&nbsp;</DIV><DIV><FONT color=#000099>&nbsp;&nbsp;&nbsp; Call </FONT>Functions.ExportToExcel(Me.Reportcontrol)</DIV><DIV>&nbsp;</DIV><DIV>Or to export only the selected rows:</DIV><DIV>&nbsp;</DIV><DIV><FONT color=#000099>&nbsp;&nbsp;&nbsp; Call </FONT>Functions.ExportToExcel(Me.Reportcontrol, <FONT color=#000099>True</FONT>)</DIV><DIV>&nbsp;</DIV><DIV>Class objects are better for this kind of dynamic code as it's more robust to store reusable code and it makes finding what functions you have available to your project easier to locate as typing the class name and pressing the "." key displays all avaliable funtions in a dropdown list.</DIV>]]>
   </description>
   <pubDate>Mon, 09 Aug 2010 03:11:55 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17020&amp;PID=59691&amp;title=copy-to-clipboard#59691</guid>
  </item> 
  <item>
   <title><![CDATA[Copy To ClipBoard : Hi,   Thanks for You Reply...!  I...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17020&amp;PID=59584&amp;title=copy-to-clipboard#59584</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6244">SHAN</a><br /><strong>Subject:</strong> 17020<br /><strong>Posted:</strong> 03 August 2010 at 7:10am<br /><br />Hi, <DIV>&nbsp;</DIV><DIV>Thanks for You Reply...!</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;I tried myself a method&nbsp; and it works...! This is the Code for Converting Report Control Data with Headers to Excel</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>------------------------------------------------------------------------------------</DIV><DIV>&nbsp;</DIV><DIV>Public Sub ReportControlToExcel(Rptcontrol As ReportControl)</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim xlObject&nbsp;&nbsp;&nbsp; As Excel.Application<BR>&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim xlWB&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As Excel.Workbook<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set xlObject = New Excel.Application<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'This Adds a new woorkbook, you could open the workbook from file also<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set xlWB = xlObject.Workbooks.Add<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Clipboard.Clear 'Clear the Clipboard</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Add Column Headers<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For i = 1 To Rptcontrol.Columns.count<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlObject.ActiveSheet.Cells(1, i).Value = _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "" &amp; Rptcontrol.Columns.Column(i - 1).Caption<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Select All Records<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For i = 0 To Rptcontrol.Rows.count - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Rptcontrol.Rows(i).Selected = True<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Copy Records to ClipBoard<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Rptcontrol.Copy<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; With xlObject.ActiveWorkbook.ActiveSheet<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Range("A2").Select 'Select Cell A2 (will paste from here, to different cells)</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Paste&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Paste clipboard contents</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End With</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Clear Selected Records from Selection<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Rptcontrol.SelectedRows.DeleteAll<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Clipboard.Clear<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Format excel Columns<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For i = 1 To Rptcontrol.Columns.count<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlObject.ActiveSheet.Columns(i).AutoFit<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlObject.ActiveSheet.Columns(i).HorizontalAlignment = xlCenter<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Format Excel Rows<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlObject.ActiveSheet.Rows(1).Font.Bold = True<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlObject.ActiveSheet.Rows(1).Interior.Color = &amp;HFFC0C0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlObject.ActiveSheet.Rows(2).Select<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Freeze the First Row<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlObject.ActiveWindow.FreezePanes = True<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' This makes Excel visible</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlObject.Visible = True</DIV><DIV><BR>End Sub</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>-----------------------------------------------------------------------------------</DIV><DIV>'To call the Method Use</DIV><DIV>&nbsp;</DIV><DIV>call ReportControlToExcel(Reportcontrol1)</DIV>]]>
   </description>
   <pubDate>Tue, 03 Aug 2010 07:10:00 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17020&amp;PID=59584&amp;title=copy-to-clipboard#59584</guid>
  </item> 
  <item>
   <title><![CDATA[Copy To ClipBoard : Hi,I actually created a specific...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17020&amp;PID=59565&amp;title=copy-to-clipboard#59565</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2960">Xander75</a><br /><strong>Subject:</strong> 17020<br /><strong>Posted:</strong> 01 August 2010 at 6:14am<br /><br />Hi,<br><br>I actually created a specific ExportToExcel function that does exaclty this. I placed it in a class and made it dynamic so I could use it with any ReportControl control on any form. However I am not at work as it's the weekend and I am also off work for the next week to get some painting done in the flat! <br><br>I will post it as soon as I can, unless anyone beats me to it.<br>]]>
   </description>
   <pubDate>Sun, 01 Aug 2010 06:14:57 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17020&amp;PID=59565&amp;title=copy-to-clipboard#59565</guid>
  </item> 
  <item>
   <title><![CDATA[Copy To ClipBoard : Hi,  You can use Copy method...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17020&amp;PID=59546&amp;title=copy-to-clipboard#59546</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=3701">Aaron</a><br /><strong>Subject:</strong> 17020<br /><strong>Posted:</strong> 30 July 2010 at 2:10pm<br /><br />Hi,<DIV>&nbsp;</DIV><DIV>You can use Copy method of ReportControl. Don't know if they will copy column headers as well...&nbsp;Another&nbsp;possibility&nbsp;is to use Excel Object and create own function to add columns and contents to Excel sheet.</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Fri, 30 Jul 2010 14:10:00 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17020&amp;PID=59546&amp;title=copy-to-clipboard#59546</guid>
  </item> 
  <item>
   <title><![CDATA[Copy To ClipBoard : Hi,   How to copy Report Control...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17020&amp;PID=59492&amp;title=copy-to-clipboard#59492</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6244">SHAN</a><br /><strong>Subject:</strong> 17020<br /><strong>Posted:</strong> 28 July 2010 at 12:49am<br /><br />Hi, <DIV>&nbsp;</DIV><DIV>How to copy Report Control data with Column Headers to ClipBoard ?.</DIV><DIV>&nbsp;</DIV><DIV>I want to&nbsp;Export data with Headers to Excel...!</DIV><DIV>&nbsp;</DIV><DIV>If clipboard&nbsp; option available it is easy to paste in excel? </DIV><DIV>&nbsp;</DIV><DIV>Any help for this?.</DIV><DIV>&nbsp;</DIV><DIV>Thanks in Advance</DIV>]]>
   </description>
   <pubDate>Wed, 28 Jul 2010 00:49:52 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17020&amp;PID=59492&amp;title=copy-to-clipboard#59492</guid>
  </item> 
 </channel>
</rss>