J
Joseph M. Newcomer
I do an operation that puts text in a text frame, and if I immediately query the Saved
property of the presentation, it is still 0.
I'm doing this from MFC using the Automation interface; the code is shown below. Am I
supposed to set the Saved property myself if I make a change?BOOL
CIndexerDlg:owerPoint::IsModified()
{
::SetLastError(ERROR_SUCCESS); // if FALSE and error success, no problem
if(!Launched) // My own test that PowerPoint has launched successfully
return FALSE;
if(!Opened) // My own test that the presentation is open
return FALSE;
try {
BOOL result = (BOOL)Presentation.get_Saved(); // Presentation.Saved property
return result;
}
catch(COleException * e)
{ /* failed */
DWORD err = e->m_sc;
e->Delete();
::SetLastError(err);
return FALSE;
} /* failed */
} // CIndexerDlg:owerPoint::IsModified
The text is appended using
void CIndexerDlg::AppendStringToNotes(CString s)
{
int n = c_IndexData.GetSelection(); // Retrieve current selection from control
if(n < 0)
return;
int id = c_IndexData.GetSlideID(n); // Get Slide ID from control
if(id == 0)
return;
int slideno;
slideno = PPT.GotoSlide(id); // View.GotoSlide(id) implemented in this; returns 0
if failure, actual slide # if found
if(slideno == 0)
{ /* failed */
DWORD err = ::GetLastError();
//*********************************************************
// For purposes of initial error reporting, set the slide #
// to be the slide # stored in the table. It may be wrong
// but it's all we have at this point
//*********************************************************
slideno = c_IndexData.GetSlideNumber(n);
// OMITTED: report error here
return;
} /* failed */
ValidSlide = slideno; // Current "valid selection" variable now holds current slide
#
s += _T("\r\n");
try
{ /* modify text */
CSlide slide = PPT.GetSlide(slideno); // Slide slide =
Presentation.Slides.Item(slideno)
CSlideRange sliderange = slide.get_NotesPage(); // SlideRange sliderange =
slide.NotesPage
CShapes shapes = sliderange.get_Shapes();
CPlaceholders placeholders = shapes.get_Placeholders();
CShape shape = placeholders.Item(2);
CTextFrame frame = shape.get_TextFrame();
CTextRange textrange = frame.get_TextRange();
if(frame.get_HasText())
{ /* text in frame */
CString text = textrange.get_Text();
if(!text.IsEmpty() && text.Right(2) != _T("\r\n"))
s = _T("\r\n") + s;
textrange.InsertAfter(s);
} /* text in frame */
else
{ /* empty notes */
textrange.put_Text(s);
} /* empty notes */
} /* modify text */
catch(COleException * e)
{ /* failed */
DWORD err = e->m_sc;
// OMITTED: Report error
e->Delete();
::SetLastError(err);
} /* failed */
} // CIndexerDlg::AppendStringToNotes
Joseph M. Newcomer [MVP]
email: (e-mail address removed)
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
property of the presentation, it is still 0.
I'm doing this from MFC using the Automation interface; the code is shown below. Am I
supposed to set the Saved property myself if I make a change?BOOL
CIndexerDlg:owerPoint::IsModified()
{
::SetLastError(ERROR_SUCCESS); // if FALSE and error success, no problem
if(!Launched) // My own test that PowerPoint has launched successfully
return FALSE;
if(!Opened) // My own test that the presentation is open
return FALSE;
try {
BOOL result = (BOOL)Presentation.get_Saved(); // Presentation.Saved property
return result;
}
catch(COleException * e)
{ /* failed */
DWORD err = e->m_sc;
e->Delete();
::SetLastError(err);
return FALSE;
} /* failed */
} // CIndexerDlg:owerPoint::IsModified
The text is appended using
void CIndexerDlg::AppendStringToNotes(CString s)
{
int n = c_IndexData.GetSelection(); // Retrieve current selection from control
if(n < 0)
return;
int id = c_IndexData.GetSlideID(n); // Get Slide ID from control
if(id == 0)
return;
int slideno;
slideno = PPT.GotoSlide(id); // View.GotoSlide(id) implemented in this; returns 0
if failure, actual slide # if found
if(slideno == 0)
{ /* failed */
DWORD err = ::GetLastError();
//*********************************************************
// For purposes of initial error reporting, set the slide #
// to be the slide # stored in the table. It may be wrong
// but it's all we have at this point
//*********************************************************
slideno = c_IndexData.GetSlideNumber(n);
// OMITTED: report error here
return;
} /* failed */
ValidSlide = slideno; // Current "valid selection" variable now holds current slide
#
s += _T("\r\n");
try
{ /* modify text */
CSlide slide = PPT.GetSlide(slideno); // Slide slide =
Presentation.Slides.Item(slideno)
CSlideRange sliderange = slide.get_NotesPage(); // SlideRange sliderange =
slide.NotesPage
CShapes shapes = sliderange.get_Shapes();
CPlaceholders placeholders = shapes.get_Placeholders();
CShape shape = placeholders.Item(2);
CTextFrame frame = shape.get_TextFrame();
CTextRange textrange = frame.get_TextRange();
if(frame.get_HasText())
{ /* text in frame */
CString text = textrange.get_Text();
if(!text.IsEmpty() && text.Right(2) != _T("\r\n"))
s = _T("\r\n") + s;
textrange.InsertAfter(s);
} /* text in frame */
else
{ /* empty notes */
textrange.put_Text(s);
} /* empty notes */
} /* modify text */
catch(COleException * e)
{ /* failed */
DWORD err = e->m_sc;
// OMITTED: Report error
e->Delete();
::SetLastError(err);
} /* failed */
} // CIndexerDlg::AppendStringToNotes
Joseph M. Newcomer [MVP]
email: (e-mail address removed)
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm