 |
VFP 愛用者社區 本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.
|
上一篇主題 :: 下一篇主題 |
發表人 |
內容 |
nmellb
註冊時間: 2014-06-07 文章: 5
第 1 樓
|
發表於: 星期一 七月 14, 2014 5:27 pm 文章主題: pictures.insert & addpicture問題 |
|
|
請教各位先進,vba代碼產生圖片,
Pictures.Insert 可依儲存格插入圖片,
但因office 2003 和office 2010的圖片檔連結路徑問題,
改成ActiveSheet.Shapes.AddPicture 方式,但需計算X,Y軸,
如果先將圖片Pictures.Insert ,如何獲得X,Y軸,再將圖片刪除,
再ActiveSheet.Shapes.AddPicture圖,可以教我方法嗎?
爬了好多文就是搞不懂~
-----
JPG_ADD="D"+ALLTRIM(STR(L+2))
MJPG=alltrim(JPG) '資料庫JPG欄位,圖片路徑
MYEXCEL.Range("&JPG_ADD").Select
MYEXCEL.ActiveSheet.Pictures.Insert("&MJPG").Select
----- |
|
回頂端 |
|
 |
ckp6250
註冊時間: 2004-07-30 文章: 1645
第 2 樓
|
發表於: 星期一 七月 14, 2014 5:45 pm 文章主題: |
|
|
代碼: |
Function Excel_插入圖片(vPic)
LOCAL vRow,vCol
with eole
vRow = .ActiveCell.Row
vCol = .ActiveCell.Column
.cells(vRow, vCol).Select
.ActiveSheet.PictureS.Insert(vPic).Select
With .Selection
.Top = eole.cells(vRow, vCol).Top + 2
.Left = eole.cells(vRow, vCol).Left + 4
Endwith
endwith
Endfunc
|
|
|
回頂端 |
|
 |
nmellb
註冊時間: 2014-06-07 文章: 5
第 3 樓
|
發表於: 星期二 七月 15, 2014 9:04 am 文章主題: |
|
|
需要的是ActiveSheet.Shapes.AddPicture 方式  |
|
回頂端 |
|
 |
syntech
註冊時間: 2003-05-16 文章: 4249 來自: Taipei,Taiwan
第 4 樓
|
發表於: 星期二 七月 15, 2014 9:26 am 文章主題: |
|
|
-------
oSheet.Shapes.AddPicture(cFileName, lLinkToFile, lSaveWithDocument,
nLeft, nTop, nWidth, nHeight)
cFileName
Character
The fully pathed filename of the picture.
lLinkToFile
Logical
Indicates whether to link the picture to the file from which it was created or to create a copy inside the document.
lSaveWithDocument
Logical
Indicates whether to save the linked picture with the file or to store only the link information in the document. This argument must be True if lLinkToFile is False.
nLeft,
nTop
Numeric
The position (in points) of the upper-left corner of the picture, measured from the upper-left corner of the spreadsheet.
nWidth,
nHeight
Numeric
The width and height of the picture, in points.
--------
EX:
LogoFile = "C:\COMPANY\LOGO2.JPG"
OleEXCEL.ActiveWorkbook.Sheets(1).Shapes.AddPicture(LogoFile, .T., .T., 0, 15, 72, 72)
但你用shape 物件貼圖,位置是"浮"在整個sheet上面.
所以你要自己算 xy,
excel 很機車,
畫面上有好幾種單位,
shape 的 xy 單位用的是 point,
http://www.dotblogs.com.tw/larrynung/archive/2012/05/27/72424.aspx
pixels = point * 96 / 72
point = pixel * 72 / 96
所以你要從column及row的寬高合計,轉成POINT,
才是你shape的 xy值 _________________ 如果公司有下列困擾:
1. 找不到便宜,快速,簡易的 生產排程軟體
2. 不知道如何快速排定 採購計劃
3. 成本抓不準,自己算比軟體算有用
4. 想學習系統規劃,想找系統架構的顧問
請聯絡我們,也許我們幫得上忙
syntech 在 星期二 七月 15, 2014 9:29 am 作了第 1 次修改 |
|
回頂端 |
|
 |
syntech
註冊時間: 2003-05-16 文章: 4249 來自: Taipei,Taiwan
第 5 樓
|
發表於: 星期二 七月 15, 2014 9:28 am 文章主題: |
|
|
最後,
你會發現 公式都對,但是圖貼出來的位置就是差一點.
(還好,誤差不大)
m$ ,真是搞不懂你呀. _________________ 如果公司有下列困擾:
1. 找不到便宜,快速,簡易的 生產排程軟體
2. 不知道如何快速排定 採購計劃
3. 成本抓不準,自己算比軟體算有用
4. 想學習系統規劃,想找系統架構的顧問
請聯絡我們,也許我們幫得上忙 |
|
回頂端 |
|
 |
ckp6250
註冊時間: 2004-07-30 文章: 1645
第 6 樓
|
發表於: 星期二 七月 15, 2014 3:04 pm 文章主題: |
|
|
搞這麼複雜做什麼呢?
是要做浮水印嗎?
否則,指定一個儲存格,貼到那個格子去,
不行嗎? |
|
回頂端 |
|
 |
syntech
註冊時間: 2003-05-16 文章: 4249 來自: Taipei,Taiwan
第 7 樓
|
發表於: 星期三 七月 16, 2014 9:13 am 文章主題: |
|
|
依格子貼圖,圖的位置就被格子綁住.
也連帶會綁住整個sheet,
因為會為了在某個cell貼圖而調整整個版面. _________________ 如果公司有下列困擾:
1. 找不到便宜,快速,簡易的 生產排程軟體
2. 不知道如何快速排定 採購計劃
3. 成本抓不準,自己算比軟體算有用
4. 想學習系統規劃,想找系統架構的顧問
請聯絡我們,也許我們幫得上忙 |
|
回頂端 |
|
 |
nmellb
註冊時間: 2014-06-07 文章: 5
第 8 樓
|
發表於: 星期三 七月 16, 2014 12:03 pm 文章主題: |
|
|
不是做浮水印,是因為在vfp 6 ,pictures.insert的語法,
轉出office 2003 excel,圖片在本地電腦和傳給客戶都沒有問題,
但另一台電腦office 2010版本,轉出的圖片發給客戶變成了連結,
才爬文爬了好久,說用addpicture方式,但圖片位置整個都算不準了,
所以來問問先進~但...問題還是沒有好的解決方式~  |
|
回頂端 |
|
 |
perry
註冊時間: 2014-07-20 文章: 203
第 9 樓
|
發表於: 星期日 七月 20, 2014 2:45 pm 文章主題: |
|
|
試看看!!
代碼: |
priv otest_fm,p_w,p_h
store 0 to p_w,p_h
otest_fm=crea('form1')
otest_fm.show
define class form1 as form
add object image1 as image
proc init
with this.image1
.top=0
.left=0
.visible=.f.
.stretch=0
endwith
this.image1.picture='yourpict'
p_w=this.image1.width
p_h=this.image1.height
*小測excel 插入圖片的寬高是像素的0.75
*所以 int(p_w*0.75)+1,int(p_h*0.75)+1 就是excel 的寬高
*縮圖則不知了!!
endproc
enddefine
|
|
|
回頂端 |
|
 |
|
|
您 無法 在這個版面發表文章 您 無法 在這個版面回覆文章 您 無法 在這個版面編輯文章 您 無法 在這個版面刪除文章 您 無法 在這個版面進行投票 您 無法 在這個版面附加檔案 您 無法 在這個版面下載檔案
|
|