dirs= dir;

dirnames = {};
ctrnames = 1;
for idxaam =   3:  length( dirs),
    if dirs(idxaam).isdir,
        dirnames{ ctrnames } = dirs(idxaam).name;
        ctrnames = ctrnames + 1;
    end
    
end
    
    
    

ctratp = 1;

h = actxserver('PowerPoint.Application');
Presentation = h.Presentation.Add;



for idxaam =   1: 2 : length( dirnames)-1,
       cd( dirnames{idxaam} );
      
       Slide = Presentation.Slides.Add( ctratp, 'ppLayoutBlank');
       if exist( 'Alt_merged_cropped.png')>0,                
           filename = [pwd '\Alt_merged_cropped.png'];
       else
           filename = [pwd '\merged_cropped.png'];
       end
           
       im = imread( filename );
       [ ih, iw, d] = size(im);
       clear im;
       sw = Presentation.PageSetup.SlideWidth;
       sh = Presentation.PageSetup.SlideHeight; 
       
       ph = round( sh/2 - 40 );
       pw = round( ph*iw/ih );
       
       if pw > sw,
           ph = ph* sw/pw;
           pw = sw;
       end
       
%        Insert top picture
       Slide.Shapes.AddPicture( filename , 'msoFalse','msoTrue',0,30,pw, ph );                    
       Title = Slide.Shapes.AddTextbox('msoTextOrientationHorizontal',0,5,sw, 40);
       Title.TextFrame.TextRange.Text = [dirnames{idxaam} ];
       
%        Insert A
       Title = Slide.Shapes.AddTextbox('msoTextOrientationHorizontal', pw-40,ph, 20, 20);
       Title.TextFrame.TextRange.Text = 'A';
       
       cd ..;
%        disp(dirnames{idxaam+1})
       cd( dirnames{idxaam+1} );

       if exist( 'Alt_merged_cropped.png')>0,                
           filename = [pwd '\Alt_merged_cropped.png'];
       else
           filename = [pwd '\merged_cropped.png'];
       end
       
%        Insert bottom pic
       Slide.Shapes.AddPicture( filename , 'msoFalse','msoTrue',0, ph+60  ,pw, ph );                      
       Title = Slide.Shapes.AddTextbox('msoTextOrientationHorizontal',0,ph+30 ,sw, 40);
       Title.TextFrame.TextRange.Text = [dirnames{idxaam+1} ];
       
       %        Insert B
       Title = Slide.Shapes.AddTextbox('msoTextOrientationHorizontal', pw-40, 2*ph+40, 20, 20);
       Title.TextFrame.TextRange.Text = 'B';
       
       ctratp = ctratp + 1;
        
%        Slide = Presentation.Slides.Add( (ctratp*2), 'ppLayoutBlank');
%        filename = [pwd '\FlowPerUnit_eps.png'];
%        im = imread( filename );
%        [ ih, iw, d] = size(im);
%        clear im;
%        sw = Presentation.PageSetup.SlideWidth;
%        sh = Presentation.PageSetup.SlideHeight;       
%        Slide.Shapes.AddPicture( filename , 'msoFalse','msoTrue',0.1* sw, 0.1 * sh, round(iw * (0.8*sh/ih)) , round(0.8*sh) );     
%        Title = Slide.Shapes.AddTextbox('msoTextOrientationHorizontal',0,5,sw, 70);
%        Title.TextFrame.TextRange.Text = [ dirs(idxaam).name,  ' Flow per lithologic unit per cell'];       
       
       
%        Slide = Presentation.Slides.Add( (ctratp*3)-1, 'ppLayoutBlank');
%        Slide.Shapes.AddPicture( [pwd '\Head_eps.png'] , 'msoFalse','msoTrue',100,20,500,500 )
%        
%        Title = Slide.Shapes.AddTextbox('msoTextOrientationHorizontal',200,10,400,70);
%        Title.TextFrame.TextRange.Text = [ dirs(idxaam).name,  ' Hydraulic Head'];
% 
%        
%        Slide = Presentation.Slides.Add( (ctratp*3), 'ppLayoutBlank');
%        Slide.Shapes.AddPicture( [pwd '\FlowPerUnit_eps.png'] , 'msoFalse','msoTrue',100,20,500,500 )
%        
%        Title = Slide.Shapes.AddTextbox('msoTextOrientationHorizontal',200,10,400,70);
%        Title.TextFrame.TextRange.Text = [ dirs(idxaam).name, ' Flow per lithologic unit per cell'];       
       
       cd ..;
    
end
saveasname = [pwd , '\ModelResults', datestr(now, 'yyyy_mm_dd HH_MM_SS'), '.ppt'];
Presentation.SaveAs( saveasname )

h.Quit;
h.delete;