# Need Example of Macro in Microsoft Publisher to change format of tables



## andreagreengard (Nov 3, 2014)

I have a 2 publisher files with over 50 pages each, and each page has 2 or 3 tables. i need to write a macro to remove the background color (and change other formats) to the table. Any example code would be very helpful as i am new at macros.

If i can't figure this out, i will have to manually change all the tables by hand.


----------



## Corday (Mar 3, 2010)

Partial answer in this forum: Macro to change background color | Microsoft Office Forums


----------



## andreagreengard (Nov 3, 2014)

but, that is for the background. i am not sure how to reference the tables themselves? any extra advice? i am new to macros :/


----------



## Corday (Mar 3, 2010)

This is old, but useful: Programming Publisher 2003 Made Easy: Lesson 1
If you're going to undertake tasks like this on a regular basis, it would be beneficial to learn VBA code.


----------



## andreagreengard (Nov 3, 2014)

thanks for sending that. i have actually looked at the page already.can you direct me to a list of how to reference objects? because i dont know how to "call" the table? or, does that macro progam help me in some way, because i am not able to see a list of objects in my document or thier properties. but i may be looking in the wrong area once i open the macro editor

i am a web developer so i can read and write code (asp, php, html, .net, etc), i just dont know the syntax of this or where to see examples...


----------



## Corday (Mar 3, 2010)

Is this what you mean? Move an object forward or backward - Publisher


----------



## andreagreengard (Nov 3, 2014)

no, i need to know how to write a macro that will remove all the background colors from the 100+ tables in my 50+ page document...


----------



## Corday (Mar 3, 2010)

I'm putting this to staff for more help. Prior to them seeing it, can you post the formula you've already tried since it might just need debugging. Also, what year version of Publisher you're using since it makes a difference.


----------



## andreagreengard (Nov 3, 2014)

i am using Publisher 2010. I don't have any formula because I don't know how to write one to reference the tables...


----------



## andreagreengard (Nov 3, 2014)

im sorry to be so new at this.. i just dont know how to properly reference anything or the syntax so i was looking for some straight up examples of a macro that changes table background colors in an entire document


----------



## andreagreengard (Nov 3, 2014)

so, I am trying this:

Sub test()
Dim t As Table

For Each t In ActiveDocument.Tables

.Texture = wdTextureNone
.ForegroundPatternColor = white
.BackgroundPatternColor = white

Next
End Sub

and my error is Compile error: method or data memeber not found, and then it highlights the ".Table" part in the FOR EACH line...


----------



## andreagreengard (Nov 3, 2014)

trying this to ut it gives an error:

For Each pubPage In ActiveDocument.Pages
For Each pubShape In pubPage.Shapes
If pubShape.Type = pbTable Then

ActiveDocument.Pages.Table.Cells.Fill = "white"


End If
Next pubShape
Next pubPage


and this one didn't give an error but did nothing
Sub test()
Dim pubPage As Page
Dim pubShape As Shape
For Each pubPage In ActiveDocument.Pages
For Each pubShape In pubPage.Shapes
If pubShape.Type = pbTable Then

ForegroundPatternColor = white
BackgroundPatternColor = white
End If
Next pubShape
Next pubPage
End Sub


----------



## andreagreengard (Nov 3, 2014)

no ideas huh? i have already started to manually change the tables, but i would like to know how to do this..


----------



## Corday (Mar 3, 2010)

Asked staff in both MS and Programing. No response. Although some are reluctant to actually originate the code, I felt they might jump in to debug.


----------

