Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-30-2014, 08:59 AM
bgranzow bgranzow is offline Help Writing VBA Code using the HideMark property Windows 8 Help Writing VBA Code using the HideMark property Office 2013
Novice
Help Writing VBA Code using the HideMark property
 
Join Date: Jan 2014
Posts: 12
bgranzow is on a distinguished road
Question Help Writing VBA Code using the HideMark property


Hello,
I am running office 2013. In word, I have a table with rows. These rows are filled by a mail merge. Sometimes, the rows are completely empty. When this occurs, I would like the rows to automatically shrink to size 0. Currently they cannot do so because of the hidden next cell glyph in each cell. I know there is a way to use VBA and the HideMark property to tell word to ignore those glyphs when defining the cell height however, I'm not sure how to go about writing the code for it. Please Help. Thank you.

Here is a link to what I need to do.
http://officeopenxml.com/WPhideMark.php
Reply With Quote
  #2  
Old 05-30-2014, 02:52 PM
macropod's Avatar
macropod macropod is offline Help Writing VBA Code using the HideMark property Windows 7 32bit Help Writing VBA Code using the HideMark property Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The preferred way of handling this would be to not create the unwanted rows in the first place. How you go about doing that depends on whether you need a variable number of rows or whether some required rows simply have no data (e.g. a row for a cell phone but the record doesn't have one).

The alternative would be to use a macro to delete, not just hide, the rows post-merge.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 06-02-2014, 06:52 AM
bgranzow bgranzow is offline Help Writing VBA Code using the HideMark property Windows 8 Help Writing VBA Code using the HideMark property Office 2013
Novice
Help Writing VBA Code using the HideMark property
 
Join Date: Jan 2014
Posts: 12
bgranzow is on a distinguished road
Default

The problem is that whether the row is filled or not depends on a number of variables in the records I am sinking. And at over 300 records, manual deletion would be a pain. Does anyone know how to write the VBA code for the Hidemark property?
Reply With Quote
  #4  
Old 06-02-2014, 08:02 AM
jpb103's Avatar
jpb103 jpb103 is offline Help Writing VBA Code using the HideMark property Windows 7 64bit Help Writing VBA Code using the HideMark property Office 2007
Advanced Beginner
 
Join Date: May 2014
Location: Thunder Bay, Ontario
Posts: 58
jpb103 is on a distinguished road
Default

What do you mean by manual deletion? You could just write a macro to delete every row with no data, it shouldn't take that long to process. I personally haven't heard of the Hidemark property until seeing this post.
Reply With Quote
  #5  
Old 06-02-2014, 08:05 AM
bgranzow bgranzow is offline Help Writing VBA Code using the HideMark property Windows 8 Help Writing VBA Code using the HideMark property Office 2013
Novice
Help Writing VBA Code using the HideMark property
 
Join Date: Jan 2014
Posts: 12
bgranzow is on a distinguished road
Default

I'm not sure that a macro that runs post merge will work for our application but can you link me to the code for one and I will work on implementing it and making it work. Thanks.
Reply With Quote
  #6  
Old 06-02-2014, 09:01 AM
jpb103's Avatar
jpb103 jpb103 is offline Help Writing VBA Code using the HideMark property Windows 7 64bit Help Writing VBA Code using the HideMark property Office 2007
Advanced Beginner
 
Join Date: May 2014
Location: Thunder Bay, Ontario
Posts: 58
jpb103 is on a distinguished road
Default

Just pop a command button on your document and give this code a try:
Code:
'///////////////////////////////////////////////////////////
'//////////////////CommandButton1_Click/////////////////////
'/////This function deletes all empty rows from a table/////
'///////////////////////////////////////////////////////////
Private Sub CommandButton1_Click()
For Each Row In ActiveDocument.Tables(1).Rows
    'MsgBox Row.Cells(1).Range.Text
    If (Row.Cells(1).Range.Text = Chr(13) & Chr(7)) Then Row.Delete
Next Row
'/////////////////////////END///////////////////////////////
End Sub
Keep in mind that this code only checks the first (i.e. leftmost) cell in each row to see if it is empty.
*EDIT* Woops, you can remove the MsgBox line (it's commented out anyways). I was using it for testing.
Reply With Quote
  #7  
Old 06-02-2014, 10:03 AM
bgranzow bgranzow is offline Help Writing VBA Code using the HideMark property Windows 8 Help Writing VBA Code using the HideMark property Office 2013
Novice
Help Writing VBA Code using the HideMark property
 
Join Date: Jan 2014
Posts: 12
bgranzow is on a distinguished road
Default

Great thanks! I'll give this a try and see what I can do to make it work for us.
Reply With Quote
  #8  
Old 06-02-2014, 04:10 PM
macropod's Avatar
macropod macropod is offline Help Writing VBA Code using the HideMark property Windows 7 32bit Help Writing VBA Code using the HideMark property Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by bgranzow View Post
The problem is that whether the row is filled or not depends on a number of variables in the records I am sinking. And at over 300 records, manual deletion would be a pain. Does anyone know how to write the VBA code for the Hidemark property?
I wasn't suggesting manual deletion - it can be done quite easily with a macro. I also suggested you might consider re-doing the mailmerge so it only creates those rows you actually require.

The code provided by jpb103 will delete (not just hide) the entire row if even just the first cell on the row is empty. It's not clear whether that's what you want, or whether the entire row must be empty.

At this stage, you haven't provided enough information for anyone to know what kind of table your mailmerge generates. For example, do the number of records for each table vary, or is it that some records have empty fields. If it's the former, a Directory merge may be the way to go, instead of the Letter merge you're now using.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
hidemark, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Link Watermark to custom property kerend Word 0 04-08-2012 05:03 AM
Help Writing VBA Code using the HideMark property QuickParts - custom document property untttt Word 2 06-09-2011 05:24 PM
Help Writing VBA Code using the HideMark property Access to the property of the current table b0x4it Word VBA 2 05-26-2011 06:25 AM
Writing code with C# and VB.NET to create Outlook add-ins and other projects kistou Outlook 0 01-13-2010 04:23 AM
set icon for user property nav1982 Outlook 0 11-11-2009 05:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:54 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft