PCDVD數位科技討論區
PCDVD數位科技討論區   註冊 常見問題 標記討論區為已讀

回到   PCDVD數位科技討論區 > 其他群組 > 疑難雜症區
帳戶
密碼
 

回應
 
主題工具
艾唯
Regular Member
 
艾唯的大頭照
 

加入日期: Aug 2004
文章: 68
[問題]有關於excel的巨集功能

我們公司之前的人有用EXCEL寫出一個巨集~
然後我們的紙張是特殊的~
結果單獨印~是正常的~用巨集跑~會變成A4的格式
因為那個人已經離職了,所以我想問問有什麼方法可以解決呢?
也在印表機伺服器設定好特定紙張的尺寸了
     
      
__________________
喜歡發呆的小咪...........+喜歡睡覺的阿比...............................他們居然會玩GBA
舊 2005-11-23, 02:59 PM #1
回應時引用此文章
艾唯離線中  
peter1
Amateur Member
 

加入日期: Sep 2003
文章: 34
引用:
作者艾唯
我們公司之前的人有用EXCEL寫出一個巨集~
然後我們的紙張是特殊的~
結果單獨印~是正常的~用巨集跑~會變成A4的格式
因為那個人已經離職了,所以我想問問有什麼方法可以解決呢?
也在印表機伺服器設定好特定紙張的尺寸了


macro內應該有這一段:
代碼:
With ActiveSheet.PageSetup
   .PaperSize = xlPaperA4   '附註:這裡的xlPaperA4是將紙張設為A4 size
End With

可以把這一行.PaperSize = xlPaperA4 由程式碼內給disable掉
 
舊 2005-11-23, 09:35 PM #2
回應時引用此文章
peter1離線中  
c715881
New Member
 

加入日期: Dec 2003
您的住址: 台灣新竹
文章: 9
看程式碼是比較準的
如果可以的話貼上來吧
舊 2005-11-23, 10:50 PM #3
回應時引用此文章
c715881離線中  
艾唯
Regular Member
 
艾唯的大頭照
 

加入日期: Aug 2004
文章: 68
明天到公司我再把程式碼貼出來~

謝謝各位的解說^^
__________________
喜歡發呆的小咪...........+喜歡睡覺的阿比...............................他們居然會玩GBA
舊 2005-11-23, 11:14 PM #4
回應時引用此文章
艾唯離線中  
艾唯
Regular Member
 
艾唯的大頭照
 

加入日期: Aug 2004
文章: 68
不知道這段是不是
=============================================
Sub 進貨確定()
'
' 進貨確定 巨集表
' sd 在 2000/6/17 錄製的巨集
'

'
Sheets("進貨列印").Visible = True
Sheets("進貨列印").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Sheets("進貨資料").Visible = True
Sheets("進貨資料").Select
Range("A17").Select
ActiveSheet.Unprotect
Selection.EntireRow.Insert
Selection.EntireRow.Insert
Selection.EntireRow.Insert
Selection.EntireRow.Insert
Selection.EntireRow.Insert
Selection.EntireRow.Insert
Selection.EntireRow.Insert
Selection.EntireRow.Insert
Selection.EntireRow.Insert
Selection.EntireRow.Insert
Selection.EntireRow.Insert
Range("A4:H14").Select
Selection.Copy
Range("A17").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("A17").Select
Application.CutCopyMode = False
Range("A16:H30000").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("E1:E2"), Unique:=False
ActiveWindow.SmallScroll Down:=-9
Selection.EntireRow.Insert
Range("A19").Select
Selection.CurrentRegion.Select
Selection.EntireRow.Delete
Range("A17").Select
Selection.EntireRow.Delete
ActiveSheet.ShowAllData
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("進貨資料").Visible = False
Sheets("進貨設定").Select
Range("D7:E16").Select
Selection.ClearContents
Range("D7").Select
Sheets("進貨設定").Visible = False
Sheets("進貨列印").Visible = False
ActiveWorkbook.Save
Sheets("進貨首頁").Select
Range("D8:H8").Select

End Sub
Sub 進貨設定()
'
' 進貨設定 巨集表
' sd 在 2000/6/19 錄製的巨集
'

'
Sheets("進貨設定").Visible = True
Sheets("進貨設定").Select
Range("D4").Select
ActiveCell.FormulaR1C1 = "=TODAY()"
Range("D4").Select

End Sub
Sub 進貨查詢確定()
'
' 進貨查詢確定 巨集表
' sd 在 2000/6/18 錄製的巨集
'

'
Sheets("進貨資料").Visible = True
Sheets("進貨資料").Select
ActiveSheet.Unprotect
Sheets("進貨查詢").Select
ActiveSheet.Unprotect
Range("A10").Select
Selection.CurrentRegion.Select
Selection.ClearContents
Range("A10").Select
Sheets("進貨資料").Range("A16:G5000").AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Range("b5:e6"), CopyToRange:=Range("A10"), Unique:=False
Selection.CurrentRegion.Select
With Selection.Interior
.ColorIndex = 34
.Pattern = xlSolid
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("C10").Select
Selection.Sort Key1:=Range("C11"), Order1:=xlDescending, Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("進貨資料").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("進貨資料").Visible = False
Sheets("進貨查詢").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Range("A10").Select

End Sub
Sub 進貨離開()
'
' 進貨離開 巨集表
' sd 在 2000/6/17 錄製的巨集
'

'
Range("d4,D7:E16").Select
Selection.ClearContents
Range("D7").Select
Sheets("進貨設定").Visible = False
Sheets("進貨首頁").Select
Range("D8:H8").Select

End Sub
Sub 進貨查詢()
'
' 進貨查詢 巨集表
' sd 在 2000/6/19 錄製的巨集
'

'
Sheets("進貨查詢").Visible = True
Sheets("進貨查詢").Select
Range("b6").Select
End Sub
Sub 進貨查詢離開()
'
' 進貨查詢離開 巨集表
' sd 在 2000/6/19 錄製的巨集
'

'
ActiveSheet.Unprotect
Range("A10").Select
Selection.CurrentRegion.Select
Selection.Interior.ColorIndex = xlNone
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Selection.ClearContents
Range("b6:e6").Select
Selection.ClearContents
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Range("C6").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("進貨首頁").Select
Range("D8:H8").Select
End Sub
Sub 進貨查詢清除()
'
' 進貨查詢清除 巨集表
' sd 在 2000/6/19 錄製的巨集
'

'
ActiveSheet.Unprotect
Range("A10").Select
Selection.CurrentRegion.Select
Selection.Interior.ColorIndex = xlNone
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Selection.ClearContents
Range("b6:e6").Select
Selection.ClearContents
Sheets("進貨查詢").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Range("B6").Select

End Sub
__________________
喜歡發呆的小咪...........+喜歡睡覺的阿比...............................他們居然會玩GBA
舊 2005-11-24, 10:41 AM #5
回應時引用此文章
艾唯離線中  
ahdeng
Junior Member
 
ahdeng的大頭照
 

加入日期: Aug 2002
您的住址: 「天龍國」
文章: 795
是不是還有「Sub 進貨列印()」沒印出來?
__________________
「千金難買早知道,萬般無奈想不到。」
舊 2005-11-24, 12:53 PM #6
回應時引用此文章
ahdeng離線中  
艾唯
Regular Member
 
艾唯的大頭照
 

加入日期: Aug 2004
文章: 68
沒有捏,我已經把全部貼出來了
但是我在左邊有看到進貨列印...
我把圖檔附加上來
__________________
喜歡發呆的小咪...........+喜歡睡覺的阿比...............................他們居然會玩GBA
舊 2005-11-24, 01:03 PM #7
回應時引用此文章
艾唯離線中  
qqsr
Major Member
 
qqsr的大頭照
 

加入日期: Mar 2003
您的住址: 紅樹林
文章: 103
ActiveWindow.SelectedSheets.PrintOut Copies:=1

此段程式碼會把 作用中視窗的選用活頁簿印出 , 列印的份數為1份.

可以找找有沒有Pagesetup的關鍵字 , 沒有就表示沒有特別設定...
印表機預設是什麼紙 , 就印什麼紙....
舊 2005-11-24, 02:27 PM #8
回應時引用此文章
qqsr離線中  
peter1
Amateur Member
 

加入日期: Sep 2003
文章: 34
引用:
作者艾唯
沒有捏,我已經把全部貼出來了
但是我在左邊有看到進貨列印...
我把圖檔附加上來


那麼,在ThisWorkBook內,還有其它的macro程式碼嗎?

(以前會在ThisWorkBook設置Private Sub WorkBook_Open()的程式碼,只要一開啟時回答啟用巨集,就會觸發VBA......(我邪惡的笑了......))
舊 2005-11-25, 07:34 PM #9
回應時引用此文章
peter1離線中  


回應


POPIN
主題工具

發表文章規則
不可以發起新主題
不可以回應主題
不可以上傳附加檔案
不可以編輯您的文章

vB 代碼打開
[IMG]代碼打開
HTML代碼關閉



所有的時間均為GMT +8。 現在的時間是11:05 PM.


vBulletin Version 3.0.1
powered_by_vbulletin 2026。