ApplicationFactory.GetVstoObject Yöntem (_Worksheet)
Döndürür bir Microsoft.Office.Tools.Excel.Worksheet ana öğeyi belirtilen özgün çalışma kitabını nesnesinin işlevselliğini uzatır.
Ad alanı: Microsoft.Office.Tools.Excel
Derleme: Microsoft.Office.Tools.Excel (Microsoft.Office.Tools.Excel.dll içinde)
Sözdizimi
'Bildirim
Function GetVstoObject ( _
worksheet As _Worksheet _
) As Worksheet
Worksheet GetVstoObject(
_Worksheet worksheet
)
Parametreler
- worksheet
Tür: Microsoft.Office.Interop.Excel._Worksheet
Yerel çalışma sayfası nesnesi için genişletilmiş nesne almak.Bu parametre türü olmasına rağmen Microsoft.Office.Interop.Excel._Worksheet, genellikle geçmesi bir Microsoft.Office.Interop.Excel.Worksheet bu yöntemi nesne.
Dönüş Değeri
Tür: Microsoft.Office.Tools.Excel.Worksheet
Yerel çalışma sayfası nesnesinin işlevselliğini uzatır ana öğe.
Notlar
Bir uygulama düzeyinde Excel'de açık olan herhangi bir çalışma sayfasını özelleştirmek için eklenti, bu yöntemi çağırın.Bu yöntem oluşturur Yeni bir Microsoft.Office.Tools.Excel.Worksheet böyle bir nesne zaten oluşturulmuş, nesne.Bu yöntem sonraki çaðrýlar varolan önbelleğe alınan örnek dönmek Microsoft.Office.Tools.Excel.Worksheet nesne.Daha fazla bilgi için bkz. Word Belgelerini ve Excel Çalışma Kitaplarını Çalıştırma Zamanında Uygulama Düzeyi Eklentileri İçinde Genişletme.
[!NOT]
worksheet Parametresi türü Microsoft.Office.Interop.Excel._Worksheet, üst arabiriminin olduğu Microsoft.Office.Interop.Excel.Worksheet.Bu nedenle, bu yöntem her iki türdeki nesneleri kabul edebilirsiniz: Microsoft.Office.Interop.Excel._Worksheet ve Microsoft.Office.Interop.Excel.Worksheet.Genellikle, bir Excel çalışma sayfasına başvuru yaptığınızda, kullandığınız bir Microsoft.Office.Interop.Excel.Worksheet.
Örnekler
Aşağıdaki kod örneği oluşturur bir Microsoft.Office.Tools.Excel.Worksheet ana madde her Microsoft.Office.Interop.Excel.Workbook ana öğe içeren nesne.Çalıştır buradan bu kodu kullanmak için ThisAddIn Excel eklentisi sınıfında hedefleyen proje .NET Framework 4.
Private Sub Application_WorkbookBeforeSave( _
ByVal Wb As Microsoft.Office.Interop.Excel.Workbook, _
ByVal SaveAsUI As Boolean, _
ByRef Cancel As Boolean) Handles Application.WorkbookBeforeSave
If Globals.Factory.HasVstoObject(Wb) = True Then
For Each interopSheet As Excel.Worksheet In Wb.Worksheets
If Globals.Factory.HasVstoObject(interopSheet) = True Then
Dim vstoSheet As Worksheet = Globals.Factory.GetVstoObject(interopSheet)
If vstoSheet.Controls.Count > 0 Then
System.Windows.Forms.MessageBox.Show( _
"The VSTO controls are not persisted when you" _
+ " save and close this workbook.", _
"Controls Persistence", _
System.Windows.Forms.MessageBoxButtons.OK, _
System.Windows.Forms.MessageBoxIcon.Warning)
Exit For
End If
End If
Next
End If
End Sub
void Application_WorkbookBeforeSave(
Microsoft.Office.Interop.Excel.Workbook Wb, bool SaveAsUI,
ref bool Cancel)
{
if (Globals.Factory.HasVstoObject(Wb) == true)
{
foreach (Excel.Worksheet interopSheet in Wb.Worksheets)
{
if (Globals.Factory.HasVstoObject(interopSheet) == true)
{
Worksheet vstoSheet = Globals.Factory.GetVstoObject(interopSheet);
if (vstoSheet.Controls.Count > 0)
{
System.Windows.Forms.MessageBox.Show(
"The VSTO controls are not persisted when you"
+ " save and close this workbook.",
"Controls Persistence",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Warning);
break;
}
}
}
}
}
.NET Framework Güvenliği
- Anında arayanlar için tam güven. Bu üye kısmen güvenilen kodla kullanılamaz. Daha fazla bilgi için bkz. Kısmen güvenilen kod kitaplıklarını kullanma.
Ayrıca bkz.
Başvuru
Microsoft.Office.Tools.Excel Ad Alanı
Diğer Kaynaklar
Getting Extended Objects from Native Office Objects in Document-Level Customizations