.Saved property doesn't change

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::powerPoint::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::powerPoint::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
 
S

Steve Rindsberg

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.

Saved is a dirty flag. If the presentation's been changed in any way since the last save,
Saved will be 0 / False

There are differences, aren't there, between the way C and VB represent Bools as longs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top