Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Word 2007 Macro - How To


  • Please log in to reply

#1
PappaSmurf

PappaSmurf

    New Member

  • Member
  • Pip
  • 2 posts

Help

 

     I need to create a Macro in Word 2007 that will loop thru all of the TextFrames and set the Height to Auto / -1.

 

     Any help would be greatly appreciated.

 

     This is what I have come up with so far.

 
  Dim iframe As frame
  Dim nheight
  Dim nframes,  iloop As Integer
 
  Call ObjectCounts    ' displays counts of pictures, frames, etc.
 
  ' *** process frames ***
  nframes = ActiveDocument.Frames.Count
 
  If nframes > 0 Then
 
    For iloop = nframes To 1 Step -1           ' process backwards or frame delete gives errors
 
         Set iframe = ActiveDocument.Frames(iloop)
        
         Iframe.nheight = -1                         ' height of frame. are -1 if size adaptes to content
      
         End With
       
    Next iloop
 
 End If  ' end nframes > 0

Mark


Edited by PappaSmurf, 04 June 2015 - 10:47 PM.

  • 0

Advertisements


#2
PappaSmurf

PappaSmurf

    New Member

  • Topic Starter
  • Member
  • Pip
  • 2 posts

Guys / Ladies

 

     I have been able to finally figure out how to make this work, thanks to about 100 different forum messages that I read on the web.

 

     FYI, I have included the running code below, so others can find it.

 
Sub FrameHeightAutoSize()
'
' FrameHeightAutoSize Macro
'
'
  Dim iframe As Frame
  Dim nheight
  Dim nframes, iloop As Integer
 
  'Call ObjectCounts    ' displays counts of pictures, frames, etc.
 
  ' *** process frames ***
 
  nframes = ActiveDocument.Frames.Count
 
  If nframes > 0 Then
 
    For iloop = nframes To 1 Step -1           ' process backwards or frame delete gives errors
 
         Set iframe = ActiveDocument.Frames(iloop)
 
         'iframe.Height = iframe.Height - 1
 
         'Debug.Print iframe.Height
 
         'iframe.Height = -1                        ' height of frame. are -1 if size adaptes to content
 
         iframe.HeightRule = 0
 
         'Debug.Print iframe.Height
 
    Next iloop
 
  End If  ' end nframes > 0
 
End Sub
 

Mark :yeah:

 


  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP