2017-07-27 128 views
1

我的經驗,打開包含未捕捉到一個細胞畫面對象Excel文件往往遊移,這取決於它在被打開的電腦上。VBA調整屏幕分辨率

我在想,如果有一種解決這種性質的方法,例如用設置的分辨率參數打開excel文件?

我的利用率使用屏幕截圖和單元格將粘貼的圖片重新格式化爲所需的大小。如:

dim rng as range 
set shtemp=worksheets.add 
Set rng = shtemp.[B14:Q49] 
rng.CopyPicture Appearance:=xlScreen, Format:=xlBitmap 

shtemp.Shapes("Picture 1").Delete 
Range("A1").Select 
ActiveSheet.Paste 
'Reset the altered cells to normal in order to maintain congruency in picture size alteration 
'This line is where I have to re-adjust cell settings to match the computer/screen I am using and capture the needed range. 
      Rows("49:49").RowHeight = 13.2 
      Columns("Q").ColumnWidth = 8.11 
Set r = Range("B5:T45") 
With Selection.ShapeRange 
     .LockAspectRatio = False 
     .Top = r.Top 
     .Left = r.Left 
     .Width = r.Width 
     .height = r.height 
    End With 

回答

0

嘗試將此代碼添加到代碼中。它選擇一個範圍,並將縮放比例調整到該範圍。所以,無論Excel表的大小如何,範圍都可以放在窗口內。在範圍大小和最終範圍選項中進行調整以關注紙張的正確部分。

Range("A1:S1").Select 
ActiveWindow.Zoom = True 
Range("B5").Select