青草久久影院-青草久久伊人-青草久久久-青草久久精品亚洲综合专区-SM双性精跪趴灌憋尿调教H-SM脚奴调教丨踩踏贱奴

17站長網(wǎng)

17站長網(wǎng) 首頁 辦公 Word教程 查看內(nèi)容

Word教程:word右鍵怎么增加圖片另存為

2023-5-4 13:53| 查看: 2320 |來源: 互聯(lián)網(wǎng)

如果我們想把word中的圖片保存下來,苦惱word無法使用右鍵圖片另存為,接下來小編就為大家介紹一下如何使用VBA代碼增加圖片另存為 代碼如下: Option Explicit ...

如果我們想把word中的圖片保存下來,苦惱word無法使用右鍵圖片另存為,接下來小編就為大家介紹一下如何使用VBA代碼增加圖片另存為 word右鍵怎么增加圖片另存為 代碼如下:

Option Explicit

Private Const UnitPixel As Long = 2 Private Const EncoderQuality As String = "{1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB}"

Private Type GdiplusStartupInput GdiplusVersion As Long DebugEventCallback As Long SuppressBackgroundThread As Long SuppressExternalCodecs As Long End Type

Private Enum EncoderParameterValueType EncoderParameterValueTypeByte = 1 EncoderParameterValueTypeASCII = 2 EncoderParameterValueTypeShort = 3 EncoderParameterValueTypeLong = 4 EncoderParameterValueTypeRational = 5 EncoderParameterValueTypeLongRange = 6 EncoderParameterValueTypeUndefined = 7 EncoderParameterValueTypeRationalRange = 8 End Enum

Private Type EncoderParameter GUID(0 To 3) As Long NumberOfValues As Long Type As EncoderParameterValueType Value As Long End Type

Private Type EncoderParameters Count As Long Parameter As EncoderParameter End Type

Private Type ImageCodecInfo ClassID(0 To 3) As Long FormatID(0 To 3) As Long CodecName As Long DllName As Long FormatDescription As Long FilenameExtension As Long MimeType As Long Flags As Long Version As Long SigCount As Long SigSize As Long SigPattern As Long SigMask As Long End Type

Private Declare Function GdiplusStartup Lib "gdiplus" (Token As Long, inputbuf As GdiplusStartupInput, Optional ByVal outputbuf As Long = 0) As Long Private Declare Sub GdiplusShutdown Lib "gdiplus" (ByVal Token As Long) Private Declare Function GdipSaveImageToFile Lib "gdiplus" (ByVal hImage As Long, ByVal sFilename As Long, clsidEncoder As Any, encoderParams As Any) As Long Private Declare Function GdipDisposeImage Lib "gdiplus" (ByVal Image As Long) As Long Private Declare Function GdipCreateBitmapFromHBITMAP Lib "gdiplus" (ByVal hbm As Long, ByVal hPal As Long, Bitmap As Long) As Long Private Declare Function GdipGetImageEncodersSize Lib "gdiplus" (numEncoders As Long, Size As Long) As Long Private Declare Function GdipGetImageEncoders Lib "gdiplus" (ByVal numEncoders As Long, ByVal Size As Long, Encoders As Any) As Long

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Private Declare Function lstrlenW Lib "kernel32" (ByVal psString As Any) As Long Private Declare Function CLSIDFromString Lib "ole32" (ByVal lpszProgID As Long, pCLSID As Any) As Long Private Declare Function GdipBitmapSetResolution Lib "gdiplus" (ByVal Bitmap As Long, ByVal xdpi As Single, ByVal ydpi As Single) As Long

Public Enum ImageFileFormat Bmp = 1 Jpg = 2 Png = 3 Gif = 4 End Enum

Public Function SaveStdPicToFile(Stdpic As StdPicture, ByVal FileName As String, _ Optional ByVal FileFormat As ImageFileFormat = Jpg, _ Optional ByVal JpgQuality As Long = 80, _ Optional Resolution As Single) As Boolean

Dim CLSID(3) As Long Dim Bitmap As Long Dim Token As Long Dim Gsp As GdiplusStartupInput

Gsp.GdiplusVersion = 1 GDI+ 1.0版本 GdiplusStartup Token, Gsp 初始化GDI+ GdipCreateBitmapFromHBITMAP Stdpic.Handle, Stdpic.hPal, Bitmap If Bitmap <> 0 Then 說明我們成功的將StdPic對象轉(zhuǎn)換為GDI+的Bitmap對象了 GdipBitmapSetResolution Bitmap, Resolution, Resolution Select Case FileFormat Case ImageFileFormat.Bmp If Not GetEncoderClsID("Image/bmp", CLSID) = -1 Then SaveStdPicToFile = (GdipSaveImageToFile(Bitmap, StrPtr(FileName), CLSID(0), ByVal 0) = 0) End If Case ImageFileFormat.Jpg JPG格式可以設(shè)置保存的質(zhì)量 Dim aEncParams() As Byte Dim uEncParams As EncoderParameters If GetEncoderClsID("Image/jpeg", CLSID) <> -1 Then uEncParams.Count = 1 設(shè)置自定義的編碼參數(shù),這里為1個參數(shù) If JpgQuality < 0 Then JpgQuality = 0 ElseIf JpgQuality > 100 Then JpgQuality = 100 End If ReDim aEncParams(1 To Len(uEncParams)) With uEncParams.Parameter .NumberOfValues = 1 .Type = EncoderParameterValueTypeLong 設(shè)置參數(shù)值的數(shù)據(jù)類型為長整型 Call CLSIDFromString(StrPtr(EncoderQuality), .GUID(0)) 設(shè)置參數(shù)唯一標(biāo)志的GUID,這里為編碼品質(zhì) .Value = VarPtr(JpgQuality) 設(shè)置參數(shù)的值:品質(zhì)等級,最高為100,圖像文件大小與品質(zhì)成正比 End With CopyMemory aEncParams(1), uEncParams, Len(uEncParams) SaveStdPicToFile = (GdipSaveImageToFile(Bitmap, StrPtr(FileName), CLSID(0), aEncParams(1)) = 0) End If Case ImageFileFormat.Png If Not GetEncoderClsID("Image/png", CLSID) = -1 Then SaveStdPicToFile = (GdipSaveImageToFile(Bitmap, StrPtr(FileName), CLSID(0), ByVal 0) = 0) End If Case ImageFileFormat.Gif If Not GetEncoderClsID("Image/gif", CLSID) = -1 Then 如果原始的圖像是24位,則這個函數(shù)會調(diào)用系統(tǒng)的調(diào)色板來將圖像轉(zhuǎn)換為8位,轉(zhuǎn)換的效果會不盡人意,但也有可能系統(tǒng)不自動轉(zhuǎn)換,保存失敗 SaveStdPicToFile = (GdipSaveImageToFile(Bitmap, StrPtr(FileName), CLSID(0), ByVal 0) = 0) End If End Select End If GdipDisposeImage Bitmap 注意釋放資源 GdiplusShutdown Token 關(guān)閉GDI+。 End Function

Private Function GetEncoderClsID(strMimeType As String, ClassID() As Long) As Long Dim Num As Long Dim Size As Long Dim I As Long Dim Info() As ImageCodecInfo Dim Buffer() As Byte GetEncoderClsID = -1 GdipGetImageEncodersSize Num, Size 得到解碼器數(shù)組的大小 If Size <> 0 Then ReDim Info(1 To Num) As ImageCodecInfo 給數(shù)組動態(tài)分配內(nèi)存 ReDim Buffer(1 To Size) As Byte GdipGetImageEncoders Num, Size, Buffer(1) 得到數(shù)組和字符數(shù)據(jù) CopyMemory Info(1), Buffer(1), (Len(Info(1)) * Num) 復(fù)制類頭 For I = 1 To Num 循環(huán)檢測所有解碼 If (StrComp(PtrToStrW(Info(I).MimeType), strMimeType, vbTextCompare) = 0) Then 必須把指針轉(zhuǎn)換成可用的字符 CopyMemory ClassID(0), Info(I).ClassID(0), 16保存類的ID GetEncoderClsID = I 返回成功的索引值 Exit For End If Next End If End Function

Private Function PtrToStrW(ByVal lpsz As Long) As String Dim Out As String Dim Length As Long Length = lstrlenW(lpsz) If Length > 0 Then Out = StrConv(String$(Length, vbNullChar), vbUnicode) CopyMemory ByVal Out, ByVal lpsz, Length * 2 PtrToStrW = StrConv(Out, vbFromUnicode) End If End Function For Each cbn In Array("AutoText", "Drawing Canvas", "Organization Chart", "Diagram", "Frames", "Flowchart", "Inline Picture", "Floating Picture", "Shapes", "Inline Canvas", "Table Pictures", "AutoShapes", "Basic Shapes", "Insert Shape", "Picture", "WordArt Context Menu", "WordArt")

本文最后更新于 2023-5-4 13:53,某些文章具有時效性,若有錯誤或已失效,請在網(wǎng)站留言或聯(lián)系站長:17tui@17tui.com
·END·
站長網(wǎng)微信號:w17tui,關(guān)注站長、創(chuàng)業(yè)、關(guān)注互聯(lián)網(wǎng)人 - 互聯(lián)網(wǎng)創(chuàng)業(yè)者營銷服務(wù)中心

免責(zé)聲明:本站部分文章和圖片均來自用戶投稿和網(wǎng)絡(luò)收集,旨在傳播知識,文章和圖片版權(quán)歸原作者及原出處所有,僅供學(xué)習(xí)與參考,請勿用于商業(yè)用途,如果損害了您的權(quán)利,請聯(lián)系我們及時修正或刪除。謝謝!

17站長網(wǎng)微信二維碼

始終以前瞻性的眼光聚焦站長、創(chuàng)業(yè)、互聯(lián)網(wǎng)等領(lǐng)域,為您提供最新最全的互聯(lián)網(wǎng)資訊,幫助站長轉(zhuǎn)型升級,為互聯(lián)網(wǎng)創(chuàng)業(yè)者提供更加優(yōu)質(zhì)的創(chuàng)業(yè)信息和品牌營銷服務(wù),與站長一起進(jìn)步!讓互聯(lián)網(wǎng)創(chuàng)業(yè)者不再孤獨!

掃一掃,關(guān)注站長網(wǎng)微信

大家都在看

    熱門排行

      最近更新

        返回頂部
        主站蜘蛛池模板: 国产精品熟女人妻 | 亚洲AVAV天堂AV在线网爱情 | 青青草原91| 邻家美姨在线观看全集免费 | 91区国产福利在线观看午夜 | 色-情-伦-理一区二区三区 | 婷婷精品国产亚洲AV在线观看 | 亚洲精品在线看 | 99视频精品全部免费观看 | 嗯啊好爽视频 | 青青青青草 | 特黄特色大片免费播放器试看 | 国产精品美女久久久网站动漫 | 亚洲AV人无码综合在线观看蜜桃 | 久久久擼擼擼麻豆 | 国内精品不卡一区二区三区 | 亚洲人成网站在线播放 | 国产又湿又黄又硬又刺激视频 | 帝王被大臣们调教高肉 | 暖暖的视频完整视频免费韩国 | 日韩 国产 欧美视频二区 | 玩弄人妻少妇500系列网址 | 被高跟鞋调教丨vk | 日韩精品专区在线影院重磅 | 精品无人区麻豆乱码1区2 | 把腿张开JI巴CAO死你H教室 | 亚洲AV永久无码精品老司机蜜桃 | 久久999视频 | 美女脱了内裤张开腿让男人爽 | 噼里啪啦免费观看视频大全 | 尹人久久大香找蕉综合影院 | 欧美大香线蕉线伊人久久 | 国产色精品久久人妻无码 | 亚洲男人97色综合久久久 | 国产精品久久久久激情影院 | 免费国产成人高清在线观看视频 | 女人爽到高潮嗷嗷叫视频 | 火影忍者高清无码黄漫 | WWW国产精品人妻一二三区 | 日韩精品 电影一区 亚洲高清 | 入室强伦女教师被学生 |