0

Here is my code:

#import "C:\...\.....\....tlb"

using namespace std;

int main()
{   
    HRESULT hr = CoInitialize(NULL);
    _ApplicationPtr myApp("InDesign.Application");
    DocumentPtr myDoc = myApp->ActiveDocument;
    SwatchesPtr mySwatches = myDoc->Swatches;

    cout << "Number of Swatch: " << mySwatches->Count << endl; // count = 10

    SwatchPtr first_swatch = mySwatches->Item[1L];
    SwatchPtr second_swatch = mySwatches->Item[2L]; 

    cout << first_swatch->Name; // correctly
    cout << second_swatch->Name; // crash

    cin.get();
    return 0;
}

Why can I not access the elements? The count is 10. Any ideas?

The line SwatchPtr second_swatch = mySwatches->Item[2L]; compiles, but it is empty.

Error when accessing second_swatch->Name:

error

error

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Nindzzya
  • 1
  • 4

0 Answers0