L
Lokesh
Hi,
I'm developing a utility in Visual Basic 2005 (Professional Edition),
which can capture screen-shots and insert it in a word docuement. The below
is the code to insert the captured image in Word ( Word 2003) Document,
Imports Microsoft.Office.Core
Imports Microsoft.Vbe.Interop
Imports Word
' Inside the Sub ......
Dim WordApp As Word.Application
Dim doc As Word.Document
WordApp = New Word.Application
WordApp.Visible = False
doc = New Word.Document
doc.InlineShapes.AddPicture("filename_1.jpg", LinkToFile:=False,
SaveWithDocument:=True)
doc.ActiveWindow.Selection.MoveRight()
doc.ActiveWindow.Selection.TypeParagraph()
' ***************** The below Line (Pagebreak) throws an
Compilation Error, Refer below Explanation *****************
doc.ActiveWindow.Selection.InsertBreak(Type:=Word.wdpagebreak)
doc.InlineShapes.AddPicture("filename_2.jpg", LinkToFile:=False,
SaveWithDocument:=True)
doc.SaveAs("WordDocFilename.doc")
doc.Close()
WordApp = Nothing
MsgBox(" Screen Shot Captured")
In the above code, a compilation Error is Thrown as , " wdpagebreak" is not
a member of Word. But the same I tried in Word 2003 Macro, it works fine.
Kindly provide me a solution for the above.
Thanks In Advance,
Lokesh R
I'm developing a utility in Visual Basic 2005 (Professional Edition),
which can capture screen-shots and insert it in a word docuement. The below
is the code to insert the captured image in Word ( Word 2003) Document,
Imports Microsoft.Office.Core
Imports Microsoft.Vbe.Interop
Imports Word
' Inside the Sub ......
Dim WordApp As Word.Application
Dim doc As Word.Document
WordApp = New Word.Application
WordApp.Visible = False
doc = New Word.Document
doc.InlineShapes.AddPicture("filename_1.jpg", LinkToFile:=False,
SaveWithDocument:=True)
doc.ActiveWindow.Selection.MoveRight()
doc.ActiveWindow.Selection.TypeParagraph()
' ***************** The below Line (Pagebreak) throws an
Compilation Error, Refer below Explanation *****************
doc.ActiveWindow.Selection.InsertBreak(Type:=Word.wdpagebreak)
doc.InlineShapes.AddPicture("filename_2.jpg", LinkToFile:=False,
SaveWithDocument:=True)
doc.SaveAs("WordDocFilename.doc")
doc.Close()
WordApp = Nothing
MsgBox(" Screen Shot Captured")
In the above code, a compilation Error is Thrown as , " wdpagebreak" is not
a member of Word. But the same I tried in Word 2003 Macro, it works fine.
Kindly provide me a solution for the above.
Thanks In Advance,
Lokesh R