Saving as template kAISaveDocumentAsAction, can't find how to.

Hi, very simple question, I'm saving documents as ".ai" without problem, can't find the way to save it as ".ait", what is the kAIXXXFileFormat for templates ?
what's wrong in this code ?
thanks !
AIErr PIUEmDocument::SaveAsTemplate( const char* newFileName, bool inShowDialog)
  ASSERT(sAIDocument);
  ASSERT(sAIActionManager);
          AIErr                                                  error                                        = kNoErr;
  AIActionParamValueRef  valueParameterBlock          = NULL;
  ActionDialogStatus  dialogStatus                    = kDialogOff;
  if (inShowDialog)
  dialogStatus                    = kDialogOn;
  int aiVer = sAIDocument->GetAIVersion();
  error = sAIActionManager->AINewActionParamValue(&valueParameterBlock);
          ASSERT(!error );
  ASSERT(valueParameterBlock);
          if (!error)
  error = sAIActionManager->AIActionSetString(valueParameterBlock, kAISaveDocumentAsNameKey, newFileName);
                    ASSERT(!error);
  // file format
  error = sAIActionManager->AIActionSetString(valueParameterBlock, kAISaveDocumentAsFormatKey, kAINativeFileFormat); // what is the one for .ait ?
                    ASSERT(!error);
  if (!inShowDialog)
  // display options dialog
  error = sAIActionManager->AIActionSetBoolean(valueParameterBlock, kAISaveDocumentAsGetParamsKey, false);
                              ASSERT(!error);
  // mantain compatibility with previuos versions
  error = sAIActionManager->AIActionSetInteger(valueParameterBlock, kAINativeVersionKey, aiVer);//kAIVersion13); // NO kAIVersion13 !! must be current doc version !
                              ASSERT(!error);
  // embed all fonts
  error = sAIActionManager->AIActionSetInteger(valueParameterBlock, kAINativeEmbedAllFontsKey, 1);
                              ASSERT(!error);
//                              // a PDF rendition of the document will be saved together with native roundtrip information
//                              error = sAIActionManager->AIActionSetBoolean(valueParameterBlock, kAINativePDFCompatibilityKey, true);
//                              ASSERT(!error);
  error = sAIActionManager->PlayActionEvent( kAISaveDocumentAsAction, dialogStatus, valueParameterBlock );
                    ASSERT(!error);
          if( !error )
  sAIDocument->SetDocumentModified(false);
  return error;

I'm not sure if you need one -- an AI Template is just an AI file with a different extension. So you should be able to use kAINativeFileFormat, just make sure your newFileName ends with .ait and I think you're good to go. Or, at worst, rename it after its saved out. But try that last

Similar Messages

Maybe you are looking for