Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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