请问:将WORD某一页保存为图片怎么写
将WORD某一页保存为图片怎么写,比如一共有10页,将第3页存为图片不要用PDF打印机
* * WORD选择页另存为图片 * DECLARE long OpenClipboard IN user32 long DECLARE long CloseClipboard IN user32 DECLARE long EmptyClipboard IN User32 DECLARE long GetClipboardData IN user32 long DECLARE long GdiplusStartup IN gdiplus long@,string@,long DECLARE long GdiplusShutdown IN gdiplus long DECLARE long GdipCreateBitmapFromHBITMAP IN gdiplus long,long,long@ DECLARE long GdipDisposeImage IN gdiplus long DECLARE long GdipSaveImageToFile IN gdiplus long,string,string,long cPath = "d:\temp\test\111\" inFile = cPath + "111.doc" outFile = cPath + "111.png" stGSI = 0h01000000000000000000000000000000 pGDI = 0 GdiplusStartup(@pGDI, @stGSI, 0) wd = CREATEOBJECT("Word.Application") doc = wd.Documents.Open(inFile) nPage = 2 && 选择的页号 rng = doc.GoTo(1, 1, nPage) && 页开始位置 rng.Select rng.SetRange(rng.Start, rng.Bookmarks("\page").End) && 整个页面区域 rng.Copy &&CopyAsPicture wd.Documents.Close wd.Documents.Add wd.Selection.PasteSpecial(0, .f., 0, .f., 0, "", "") wd.ActiveDocument.InlineShapes(1).Range.CopyAsPicture ClipBitmapToFile(outFile) wd.ActiveDocument.Saved = .t. wd.Documents.Close ClearClipboard() wd.Quit GdiplusShutdown(pGDI) CLEAR ALL RETURN FUNCTION ClearClipboard() OpenClipboard(0) EmptyClipboard() CloseClipboard() ENDFUNC FUNCTION ClipBitmapToFile(cOutFile) IF OpenClipboard(0) == 0 RETURN .f. ENDIF LOCAL hClip hClip = GetClipboardData(2) IF hClip == 0 CloseClipboard() RETURN .f. ENDIF LOCAL pngGUID, hBitmap pngGUID = 0h06F47C55041AD3119A730000F81EF32E hBitmap = 0 GdipCreateBitmapFromHBITMAP(hClip, 2, @hBitmap) GdipSaveImageToFile(hBitmap, STRCONV(cOutFile+0h00,5), pngGUID, 0) GdipDisposeImage(hBitmap) CloseClipboard() RETURN .t. ENDFUNC
* * WORD分页另存 * cPath = "d:\temp\test\111\" inFile = cPath + "111.doc" wd = CREATEOBJECT("Word.Application") doc = wd.Documents.Open(inFile) FOR nPage=1 TO doc.Range.Information(4) rng = doc.GoTo(1, 1, nPage) && 页开始位置 rng.Select rng.SetRange(rng.Start, rng.Bookmarks("\page").End) && 整个页面区域 rng.Copy outFile = cPath + "page" + PADL(nPage,4,"0") + ".doc" tmpDoc = wd.Documents.Add tmpDoc.Application.Selection.Paste tmpDoc.SaveAs(outFile) tmpDoc.Close ENDFOR wd.Documents.Close wd.Quit CLEAR ALL RETURN