ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

½Ð°ÝHsiehª©¥D HPageBreaks(1).Location HpageBreak() ¤¤ªº¤Þ¼Æ 1 ªº·N¸q¬°¦ó?

½Ð°ÝHsiehª©¥D HPageBreaks(1).Location HpageBreak() ¤¤ªº¤Þ¼Æ 1 ªº·N¸q¬°¦ó?

Hsiehª©¥D,¦b¦Û°Ê¤À­¶ªº°Q½×¤¤§A¦³´£¨ì¦C¤À­¶ªº¤èªk:
Set ActiveSheet.HPageBreaks(1).Location = Range("A51")
HPageBreaks(1) ¤¤ªº¤Þ¼Æ 1 ¬O¦ó·N,§Ú¬d¤£¨ì»¡©ú,½Ð«üÂI¬°²ü?
²Ä(I)±ø½u©Î¤u§@ªí(I)©Î²Ä(I)­¶?
V98

²Ä¤@±ø¤À­¶½u
½Ð°Ñ¾\VBA»¡©ú¡A¦¹³Bªº1´N¬Oitemªº­È

HPageBreaks ª«¥ó¦¨­û
¦C¦L½d³ò¤º©Ò¦³¤ô¥­¤À­¶²Å¸¹ªº¶°¦X¡C
¤èªk
  ¦WºÙ ´y­z
Add ·|·s¼W¤ô¥­¤À­¶²Å¸¹¡C
ÄÝ©Ê
  ¦WºÙ ´y­z
Application ¦b¤£·f°tª«¥óÃѧO²Å¸¹¨Ï¥Îªº±¡ªp¤U¡A³o­ÓÄÝ©Ê·|¶Ç¦^¥Nªí Microsoft Excel À³¥Îµ{¦¡ªº Application ª«¥ó¡C·í·f°tª«¥óÃѧO²Å¸¹¨Ï¥Î®É¡A³o­ÓÄÝ©Ê·|¶Ç¦^ Application ª«¥ó¡A¥Nªí©Ò«ü©wª«¥óªº«Ø¥ßªÌ (³o­ÓÄÝ©Ê¥i¥H·f°t OLE Automation ª«¥ó¤@°_¨Ï¥Î¡A¨Ó¶Ç¦^¸Óª«¥óªºÀ³¥Îµ{¦¡)¡C°ßŪªº¡C
Count ·|¶Ç¦^¥Nªí¶°¦X¤¤ª«¥ó¼Æªº Long ­È¡C
Creator ·|¶Ç¦^ 32 ¦ì¤¸¾ã¼Æ¡A«ü¥X¥Î¥H«Ø¥ß³o­Óª«¥óªºÀ³¥Îµ{¦¡¡C°ßŪªº Long¡C
Item ¶Ç¦^¶°¦X¤¤ªº³æ¤@ª«¥ó¡C
Parent ·|¶Ç¦^©Ò«ü©wª«¥óªº¤÷ª«¥ó¡C°ßŪªº¡C
¨ä¤¤  count¬O¤À­¶½u¼Æ¶q
      item¬O«ü©w²Ä´X±ø¤À­¶½u
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

Hsiehª©¥D,没¦³§Aªº»¡©ú,¤£ª¾¹DVBAªº»¡©úÀÉ©MExcelªº»¡©úÀɬO¤À¶}ªº,´N¬O»¡Excel ¬¡­¶Ã¯ªº»¡©úÀÉ©MVBA¬O¤£¦Pªº¥­¥x,©Ò¥H·í§Ú¦bExcelªº¬¡­¶Ã¯¬O§ä¤£¨ìHPageBreaksª«¥óªº.
¦A¦^¨ì§Ú­Ìªº¥DÃD,¤À­¶½uªº³]©w´N¹³¬O¸õ­¶²Å¸¹¤@¼Ë,¥i¥H¸g¹L¹BºâµM«áµ¹HpageBreaks·í¤Þ¼Æ¨Ï¥Î¬O¶Ü?
count ·|¶Ç¦^¥Nªí¶°¦X¤¤ª«¥ó¼Æªº Long ­È, ·N«ä¬O¦pªG­n¤À­¶ªº¤u§@ªí­n¤À50­¶,¨º»òcountªº­È = 50 ¬O¶Ü?»¡©ú¤¤ªºª«¥ó¬O«ü¨C­Ó¤À­¶¬O¶Ü?
item¶Ç¦^¶°¦X¤¤ªº³æ¤@ª«¥ó¡C¬O«ü³æ¤@¤À­¶ªºLocation¶Ü?
V98

TOP

¦^´_ 3# linshin1999


    ©Î³\§A³o¼Ë«ä¦Ò·|¦n¤@ÂI
¤À­¶½u¬O«ü§A­n¤À­¶¦C¦Lªº­¶»P­¶¤§¶¡ªº¤À¹j²Å¸¹
·íEXCEL¦Û°Ê¤À­¶®É¡A·|¥H§A¤WÃä¬É»P¤UÃä¬É¤§¶¡©Ò¯à®e¯Çªº¦C¼Æ§@¬°¹w³]¤À­¶
©Ò¥H¡A·í§Aªº¤º®e¤£¶W¹L³o­Ó½d³ò®É(¤@­¶«K¯à®e¯Ç©Ò¦³¤º®e)
¨º»ò¨Ã¤£·|¦³¤À­¶½uªº²£¥Í¡A©Ò¥HcountÄݩʭȬ°0¡A¦ýÁ`­¶¼Æ¬O1
­Y¬O§A­n¤â°Ê¥[¤J¤À­¶½u(­ì¥»¤@­¶ªº¤º®e¤À¦¨2­¶)
¨º»ò¥i¨Ï¥ÎADD¤èªk¥[¤J¤À­¶½u
¥[¤J«á´N·|¦³¤@±ø¤À­¶½u
countÄݩʭȬ°1¡A¦ýÁ`­¶¼Æ¬O2
­Y­n¨ú±o³o¤@±ø¤À­¶½u¡A´N¥i¨Ï¥Î´ÁitemÄÝ©Ê
HPageBreaks(1)ªº¥Nªí·N¸q¸ò HPageBreaks.item(1)¬O¤@¼Ëªº
¦ÓLocationÄÝ©Ê¥Nªí¬O¤À­¶½u©Ò¦b¦ì¸m¡A¨Ã¤£¬O«ü¤À­¶½u¥»¨­
HPageBreaks(1).Location ³o¥yªº¸ÑÄÀ´N¬O
²Ä¤@±ø¤ô¥­¤À­¶½u©Ò¦bªºÀx¦s®æ¦ì¸m
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

1).¤À­¶:¦p¥H¥H«eµ{¦¡ªºÆ[ÂI´N¬O¸õ­¶¶Ü?§Ú­nªº´N¬O¸õ­¶±±¨î.

2)1.EXCEL¦Û°Ê¤À­¶®É¡A·|¥H§A¤WÃä¬É»P¤UÃä¬É¤§¶¡©Ò¯à®e¯Çªº¦C¼Æ§@¬°¹w³]¤À­¶.
ª©¥DExcel·|¦b¤W¤UÃä¬É¸Ëº¡«á©ñ¤W¤À­¶½u¬O¶Ü?¦pªG³o±ø¤À­¶½u¤£©M¨Ï¥ÎªÌªº·N«ä,¨Ï¥ÎªÌ¬O¥i¥H³zµ{¦¡©w­q·sªº¤À­¶¦pªG¬O³o¼Ë´N²³æ¤F.(¤£­n¥h²z·|Excel¦Û¤v¶]¥X¨Óªº¤À­¶½u´N¥i¥H¤F)
¦pªGExcel¸õ¥X¨Óªº¤À­¶¬O(¨C53­ÓLine),¨º§Ú­Ì±±¨îªº¤À­¶¤p©ó53(¨Ò¦p:50),¨º»ò§Úªº³øªíÀÉ´N¥i¥H¨C50¦C¸õ¤@­¶¬O¶Ü?

2)LocationÄÝ©Ê¥Nªí¬O¤À­¶½u©Ò¦b¦ì¸m¡A¨Ã¤£¬O«ü¤À­¶½u¥»¨­
¤À­¶½u©Ò¦bªº¦ì¸m¤£´N¬O¦b¨º¸Ì·|¸õ¤@­¶¶Ü?LocationÄÝ©Ê¥Nªí¬O¤À­¶½u©Ò¦b¦ì¸m,¦bExcelªº¤u§@ªí¤£¬O·|¦³¤@±øµê½u¶]¥X¨Ó¶Ü?¨Ã¤£¬O«ü¤À­¶½u¥»¨­,¥L­Ì¤£¬O¤@Å骺¶Ü?
V98

TOP

Hsiehª©¥DÁÂÁÂ,§Ú§ä¨ì¤F¸Ñ¨M¤è®×¤F:
Sub ¦Û°Ê¤À­¶
    Dim rows_count As Long
    Dim page_count As Long
    Dim i As Long
    Dim row_index As Long
    Dim str_row_index As String
    Dim first_row As Long
   
    ActiveWindow.View = xlPageBreakPreview
    rows_count = Range("A1").CurrentRegion.Rows.Count
    first_row = 50
    For i = first_row To rows_count Step 50
        page_count = page_count + 1
        str_row_index = "A" + Trim(Str(i + 1))
        Set ActiveSheet.HPageBreaks(page_count).Location = Range(str_row_index)
    Next i
    ActiveWindow.View = xlNormalView
End Sub
V98

TOP

        ÀR«ä¦Û¦b : ¤H¥Í³Ì¤jªº¦¨´N¬O±q¥¢±Ñ¤¤¯¸°_¨Ó¡C
ªð¦^¦Cªí ¤W¤@¥DÃD