Click here to Skip to main content
15,924,318 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralHaving Problems with CFileFind Pin
darkjedisleikas22-Nov-03 15:41
darkjedisleikas22-Nov-03 15:41 
GeneralRe: Having Problems with CFileFind Pin
Atlence22-Nov-03 16:07
Atlence22-Nov-03 16:07 
GeneralRe: Having Problems with CFileFind Pin
darkjedisleikas22-Nov-03 16:12
darkjedisleikas22-Nov-03 16:12 
GeneralRe: Having Problems with CFileFind Pin
Anonymous22-Nov-03 16:36
Anonymous22-Nov-03 16:36 
GeneralWord Automation with MFC Pin
Member 54540422-Nov-03 14:33
Member 54540422-Nov-03 14:33 
GeneralRe: Word Automation with MFC Pin
Peter Molnar22-Nov-03 16:25
Peter Molnar22-Nov-03 16:25 
GeneralRe: Word Automation with MFC Pin
Member 54540423-Nov-03 2:25
Member 54540423-Nov-03 2:25 
GeneralRe: Word Automation with MFC Pin
Peter Molnar23-Nov-03 8:28
Peter Molnar23-Nov-03 8:28 
I just have done what described above, namely I recorded a header inserting macro. This was recorded when I clicked: View/Header-Footer/Insert pic from file
Sub Fejlec()
'
' Fejlec Makró
' Rögzítés: 11/23/2003, készíto: Pepe
'
    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
        ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow.ActivePane.View.Type = wdOutlineView Then
        ActiveWindow.ActivePane.View.Type = wdPrintView
    End If
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    Selection.InlineShapes.AddPicture FileName:="c:\pic.jpg", LinkToFile:=False, SaveWithDocument:=True
End Sub


If you take a look at its contents, the if statements are useless for this task, you can delete them. (that was meant under "somewhat optimize").
What remains is:

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.InlineShapes.AddPicture FileName:="c:\pic.jpg", LinkToFile:=False, SaveWithDocument:=True


What does it mean? What it reads:
1. line: start editing the header of the current page
2. line: add a pic to the selection (i.e. header) with the given filename, and save the file within the word document not linking to it as an external file.

This is how you code this with MFC:
COleVariant vTrue((short)TRUE),vFalse((short)FALSE),vOpt((long)DISP_E_PARAMNOTFOUND, VT_ERROR);

//Creates new doc
Documents oDocs = oApp.GetDocuments();
_Document oDoc = oDocs.Add(vOpt, vOpt);

//First line
Window oWin = oApp.GetActiveWindow();
Pane oPane = oWin.GetActivePane()
View oView = oPane.GetView();
oView.SetSeekView(wdSeekCurrentPageHeader);

//Second line
Selection oSel = oApp.GetSelection();
Shapes oShapes = oSel.GetInlineShapes();
oShapes.AddPicture("c:\\pic.jpg",vFalse,vTrue,vOpt,vOpt,vOpt,vOpt,vOpt);


Some remarks:
1.The Word wrapper class was produced from Word 8 with VC6, because Word 8 is compatible with later word versions and VC6 produces one file for one type lybrary unlike VS.NET which does one file for every object in the tlb.
A similar wrapper is recommended to use.
2.The additon of different header for first file is left for you for practice, (ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True)





Peter Molnar
GeneralRe: Word Automation with MFC Pin
Member 54540423-Nov-03 14:55
Member 54540423-Nov-03 14:55 
GeneralRe: Word Automation with MFC Pin
Peter Molnar24-Nov-03 2:05
Peter Molnar24-Nov-03 2:05 
GeneralRe: Word Automation with MFC Pin
Member 54540424-Nov-03 14:12
Member 54540424-Nov-03 14:12 
GeneralRe: Word Automation with MFC Pin
Peter Molnar24-Nov-03 14:25
Peter Molnar24-Nov-03 14:25 
GeneralI need help;( Pin
EEYOREBABE22-Nov-03 11:04
EEYOREBABE22-Nov-03 11:04 
GeneralRe: I need help;( Pin
Peter Molnar22-Nov-03 12:46
Peter Molnar22-Nov-03 12:46 
GeneralFormatRange with Html Edit Control Pin
Atlence22-Nov-03 9:15
Atlence22-Nov-03 9:15 
GeneralRe: FormatRange with Html Edit Control Pin
Peter Molnar22-Nov-03 12:50
Peter Molnar22-Nov-03 12:50 
GeneralRe: FormatRange with Html Edit Control Pin
Atlence22-Nov-03 16:11
Atlence22-Nov-03 16:11 
GeneralRe: FormatRange with Html Edit Control Pin
Peter Molnar23-Nov-03 9:48
Peter Molnar23-Nov-03 9:48 
Generalgetting address of Internet Shortcut Pin
K. Shaffer22-Nov-03 9:04
K. Shaffer22-Nov-03 9:04 
GeneralRe: getting address of Internet Shortcut Pin
K. Shaffer22-Nov-03 9:13
K. Shaffer22-Nov-03 9:13 
GeneralRe: getting address of Internet Shortcut Pin
Michael Dunn22-Nov-03 16:12
sitebuilderMichael Dunn22-Nov-03 16:12 
Generalail.comSocket not blocking Pin
Shenthil22-Nov-03 8:59
Shenthil22-Nov-03 8:59 
GeneralRe: ail.comSocket not blocking Pin
Peter Molnar22-Nov-03 14:20
Peter Molnar22-Nov-03 14:20 
GeneralRe: ail.comSocket not blocking Pin
Gabriel.P.G22-Nov-03 14:53
Gabriel.P.G22-Nov-03 14:53 
GeneralSocket not blocking Pin
Shenthil23-Nov-03 17:42
Shenthil23-Nov-03 17:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.