none
Interop::Word::Table Compiler error C3293 and C2227 RRS feed

  • Question

  • Hi Every One

    I try to insert Text in a addet Table. The Compiler always give me Error.

    I develope with Visual Studio 2015 and C++/CLI.

    Schweregrad    Code    Beschreibung    Projekt    Datei    Zeile    Unterdrückungszustand

    Fehler    C3293    "Range": Verwenden Sie "default", um auf die Standardeigenschaft (Indexer) der Microsoft::Office::Interop::Word::Cell-Klasse zuzugreifen.    UWHP    J:\Visual Studio 2015\Projects\UWHP\UWHP\clWord.cpp    56   

    "Mistake C3293 to "rank": Use "default" to access the standard quality (Indexer) Microsoft:: office:: Interop:: Word:: Cell class. Studio UWHP J:\Visual 2015\Projects\UWHP\UWHP\clWord.cpp 56 "

    Fehler    C2227    Links von "->Text" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden.    UWHP    J:\Visual Studio 2015\Projects\UWHP\UWHP\clWord.cpp    56   

    "Mistake C2227 of link from "-> text" a pointer must be on classes and structure and union and generic type. Studio UWHP J:\Visual 2015\Projects\UWHP\UWHP\clWord.cpp 56"

    This is my Project:

    clWord.h

    #pragma once
    
    #ifndef __clWord_H__
    #define __clWord_H__
    
    using namespace System;
    using namespace Microsoft::Office;
    using namespace Microsoft::Office::Interop;
    using namespace Microsoft::Office::Interop;
    
    // ---------------------------------------------------------------------------
    
    public ref class  clWord {
    private:
    
    public:
    	clWord(void);
    	~clWord(void);
    	void Word_export( String^ strDatei);
    };
    
    #endif
    

    clWord.cpp

    // ---------------------------------------------------------------------------
    #include "StdAfx.h"
    #include "clWord.h"
    
    // ---------------------------------------------------------------------------
    
    clWord::clWord(void) 
    {
    }
    //-----------------------------------------------------------------------------------
    
    clWord::~clWord(void) 
    {
    }
    //-----------------------------------------------------------------------------------
    
    void clWord::Word_export(String^ strDatei) {
    	int iPosition;
    	int iInsertParagrap = false;
    	int iZeile = 30;
    	int iMaxSpalten = 3;
    	int iZ, iSp;
    	String^ strTemp = gcnew String("");
    	String^ strText = gcnew String("");
    	Microsoft::Office::Interop::Word::_Application^ oWord = gcnew Word::ApplicationClass();
    	Microsoft::Office::Interop::Word::_Document^ oDoc;
    	Microsoft::Office::Interop::Word::Table^ oTable;
    	Microsoft::Office::Interop::Word::Range^ wrdRng;
    
    	Object^ oMissing = System::Reflection::Missing::Value;
    	Object^ oEndOfDoc = gcnew String("\\endofdoc");		// endofdoc ist eine vordefinierte Textmarke 
    	Object^ oBookmark;
    	Object^ oOpenFile = gcnew String(strDatei);
    	Object^ oSaveOption;
    	try {
    		oSaveOption = Word::WdSaveOptions::wdSaveChanges;
    		oDoc = oWord->Documents->Open(oOpenFile, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
    		oWord->Visible = true;
    		strTemp = "Tab_Anfang";
    		if (oDoc->Bookmarks->Exists(strTemp)) {
    			oBookmark = gcnew String(strTemp);
    		}
    		else {
    			oBookmark = oEndOfDoc;
    		}
    		wrdRng = oDoc->Bookmarks[oBookmark]->Range;
    		oTable = oDoc->Tables->Add(wrdRng, iZeile, iMaxSpalten, oMissing, oMissing);
    		oTable->Borders->OutsideLineStyle = Word::WdLineStyle::wdLineStyleSingle;
    		oTable->Borders->OutsideColor = Word::WdColor::wdColorBlack;
    		oTable->TableDirection = Word::WdTableDirection::wdTableDirectionLtr;
    		oTable->Borders->InsideLineStyle = Word::WdLineStyle::wdLineStyleSingle;
    		oTable->Borders->InsideColor = Word::WdColor::wdColorBlack;
    		iZ = 1;
    		strText = gcnew String("Nachname Vorname");
    		for (iSp = 1; iSp <= iMaxSpalten; iSp++) {
    			oTable->Cell(iZ, iSp)->Range->Text = strText->ToString();
    		}
    	}
    	catch (Exception^ e) {
    
    	}
    }
    // ---------------------------------------------------------------------------
    
    Any Help?

    Tuesday, June 19, 2018 10:09 AM

All replies

  • Hi Frank,

    This forum is discussing the issue using English. You may translate the error message via English so that others can understand the issue exactly.

    And based on the translation of Google, the error seems relative to misusing the property.  For example, you may use the Default property to use the Range object of Word document.

    Hope it is helpful.

    Regards & Fei



    MSDN Community Support

    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.




    Wednesday, June 20, 2018 9:11 AM
    Moderator
  • Oh sorry,

    here a better translation. I don#t found this error for english.

    "Error C3293 to "Rank": Use "default" to access the standard properti (Indexer) to have access of the Microsoft:: office:: Interop:: Word:: Cell class.  UWHP J:\Visual 2015\Projects\UWHP\UWHP\clWord.cpp 56 "

    Error C2227 left of "->Text" must be a pointer classes, structure, union or generic type. UWHP J:\Visual 2015\Projects\UWHP\UWHP\clWord.cpp 56"

    I hope the willl be give more Information

    Regards

    Wednesday, June 20, 2018 3:50 PM
  • Hi Frank,

    For the Error C3293, please using the default to access the index property instead of using Cell. More about this error, you can refer the links below:

    Compiler Error C3293

    And for the C2227 error, please using the default property described above to refer the Range for the Cell. Here is the code for your reference:

    Microsoft::Office::Interop::Word::Documents^ pDocs = pWord->Documents;
    Microsoft::Office::Interop::Word::_Document^ pDoc = pDocs->Open( "");
    
    Microsoft::Office::Interop::Word::Cell^ cell = pDoc->Tables[1]->Cell(1,1);
    Microsoft::Office::Interop::Word::Range^ range = cell->default;

    Hope it is helpful.

    Regards & Fei



    MSDN Community Support 

    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    Friday, June 22, 2018 8:45 AM
    Moderator