MS VBA controlling Publisher

368 Views Asked by At

This is my first post in this site. I've found suggestions in the past provided by this site, but I never had to ask something directly such as today. I've been using Microsoft help files with the topic, but after given up and clicked on contacting Microsoft for help, it suggested to join this site.

I've been asked to create a macro to update various documents without Publisher. I never used Publisher and soon realized there's no macro record function.

The macro does functions that I need it to do with a few exceptions and 2 are listed below which i need help with.

FIND/REPLACE TEXT. I'm able to use the above function, and I'm able to replace text however in one instance the document has 2 bullet's on an outline and i need to create a 3rd. I look for the last few words on bullet 2, but can't figure out how to do a carriage return or a simple 'ENTER' like if you were to do it manually in order to start a new bullet. in Excel i use CHR(10) or CHR(13) but it doesn't seem to work here, even though i am coding in Excel. I found posts suggesting VbTab, VbCr, VbCtrl, but i never used those and can't seem to get them working.

FIND TEXT Some documents are outdated and i don't want to create a new version (the code wouldn't make any changes, however it would still SAVE AS with a new document name. I need to verify if certain words exist and only then, proceed with the changes. I found this code on Microsoft web site but... it only works the 1st time around.

.FoundTextRange - after the 2nd time around this object is always set to 'Nothing' even though i see the words i'm searching for.

    Dim objFind as FindReplace 
    Dim fFound as Boolean 
     
    Set objFind = ActiveDocument.Pages(1) _ 
     .Shapes(1).TextFrame.TextRange.Find 
    fFound = True 
     
    With objFind 
     .Clear 
     .FindText = "Urgent" 
     Do While fFound = True 
     fFound = .Execute 
     If Not .FoundTextRange Is Nothing Then 
     .FoundTextRange.Font.Bold = True 
     End If 
     Loop 
    End With

Any help would be appreciated.

Thanks,

1

There are 1 best solutions below

0
Rich On

I may have stumbled on an answer for the 2nd part. It seems the object for the publisher application is required in front of 'with Activedocument.find' = with AppPub.activedocument.find. On MS web site, it does not reference this.

The error then happens throughout the macro whenever 'Activedocument.find shows, it works once i apply the AppPub object reference.

If someone can suggest how to add new bullet points, that would be helpull.

I have other questions related to publisher...

  • How do you center a text box after it's been expanded? (i have to make it wide in order not to hide added text (wider and longer), but the wider change, only changes it to the right, not both ways.

  • how do you add a check box. The doc has existing checkboxes. When i copied the existing text box, that worked, but the box is very small. I tried Windings, but the box is different than the others.