![]() |
||
|
Regular Member
![]() ![]() 加入日期: Aug 2004
文章: 68
|
[問題]有關於excel的巨集功能
我們公司之前的人有用EXCEL寫出一個巨集~
然後我們的紙張是特殊的~ 結果單獨印~是正常的~用巨集跑~會變成A4的格式 因為那個人已經離職了,所以我想問問有什麼方法可以解決呢? 也在印表機伺服器設定好特定紙張的尺寸了
__________________
喜歡發呆的小咪...........+喜歡睡覺的阿比...............................他們居然會玩GBA
|
|||||||
|
|
|
Amateur Member
![]() 加入日期: Sep 2003
文章: 34
|
引用:
macro內應該有這一段: 代碼:
With ActiveSheet.PageSetup .PaperSize = xlPaperA4 '附註:這裡的xlPaperA4是將紙張設為A4 size End With 可以把這一行.PaperSize = xlPaperA4 由程式碼內給disable掉 |
|||
|
|
|
New Member
加入日期: Dec 2003 您的住址: 台灣新竹
文章: 9
|
看程式碼是比較準的
如果可以的話貼上來吧 |
|
|
|
Regular Member
![]() ![]() 加入日期: Aug 2004
文章: 68
|
明天到公司我再把程式碼貼出來~
謝謝各位的解說^^
__________________
喜歡發呆的小咪...........+喜歡睡覺的阿比...............................他們居然會玩GBA
|
|
|
|
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
|
|
|
|
Junior Member
![]() ![]() ![]() 加入日期: Aug 2002 您的住址: 「天龍國」
文章: 795
|
是不是還有「Sub 進貨列印()」沒印出來?
__________________
「千金難買早知道,萬般無奈想不到。」 |
|
|
|
Regular Member
![]() ![]() 加入日期: Aug 2004
文章: 68
|
沒有捏,我已經把全部貼出來了
但是我在左邊有看到進貨列印... 我把圖檔附加上來
__________________
喜歡發呆的小咪...........+喜歡睡覺的阿比...............................他們居然會玩GBA
|
|
|
|
Major Member
![]() 加入日期: Mar 2003 您的住址: 紅樹林
文章: 103
|
ActiveWindow.SelectedSheets.PrintOut Copies:=1
此段程式碼會把 作用中視窗的選用活頁簿印出 , 列印的份數為1份. 可以找找有沒有Pagesetup的關鍵字 , 沒有就表示沒有特別設定... 印表機預設是什麼紙 , 就印什麼紙.... |
|
|
|
Amateur Member
![]() 加入日期: Sep 2003
文章: 34
|
引用:
那麼,在ThisWorkBook內,還有其它的macro程式碼嗎? (以前會在ThisWorkBook設置Private Sub WorkBook_Open()的程式碼,只要一開啟時回答啟用巨集,就會觸發VBA......(我邪惡的笑了......)) |
|
|
|