Excel VBA Paste of Range with PrefixCharacter fails from VB.NET

  • Thread starter Thread starter Nicholas Dreyer
  • Start date Start date
N

Nicholas Dreyer

Operating System: Microsoft Windows Version 5.1 (Build
2600.xpsp_sp2_gdr.050301-1519 : Service Pack 2)

Visual Basic: MIcrosoft Visual Basic 6.3 Version 9972 VBA: Retail
6.4.9972 Forms3: 11.0.6550 (comes with Excel 2003)

The code below fails to copy the PrefixCharacter from cell "a1" to
cell "a2", yet doing the same directly from VBA code does copy the
PrefixCharacter.
_______________________________________________


With Microsoft.Office.Interop.Excel.Application.Activesheet
.Range("a1").Copy()
.Range("a2").PasteSpecial(Paste:=xlFormulas)
.Range("a2").PasteSpecial(Paste:=xlFormats)
End WIth


The following library references are used in the VB.NET project:

Assembly Microsoft.Office.Interop.Excel
C:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Excel\
11.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll

Assembly office
C:\WINDOWS\assembly\GAC\Office\11.0.0.0__71e9bce111e9429c\
Office.dll

Assembly Microsoft.VisualBasic.Compatibility
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\
Microsoft.VisualBasic.Compatibility.dll

Assembly System
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\
System.dll

Assembly System.Data
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\
System.Data.dll

Assembly System.Windows.Forms
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\
System.Windows.Forms.dll

Assembly Interop.VBA
C:\vb\Nick\PlanningToolsModules\bin\
Interop.VBA.dll

Assembly Microsoft.Vbe.Interop

C:\WINDOWS\assembly\GAC\Microsoft.Vbe.Interop\11.0.0.0__71e9bce111e9429c\
Microsoft.Vbe.Interop.dll

and the following "Imports" statements are included:


Imports Microsoft.Office.Interop.Excel
Imports Microsoft.Office.Interop.Excel.Constants
Imports Microsoft.Office.Interop.Excel.XlLookAt
Imports Microsoft.Office.Interop.Excel.XlSearchOrder
Imports Microsoft.Office.Interop.Excel.XlFindLookIn
Imports Microsoft.Office.Interop.Excel.XlDirection
Imports Microsoft.Office.Interop.Excel.XlAxisType
Imports Microsoft.Vbe.Interop
Imports Microsoft.Vbe.Interop.vbext_ComponentType


Thanks for any clues! Nick
 
I've never worked with the code version you are using but since the copy
command is to initiate an Excel event, try it without the ( )
parentheses.
 
Back
Top