EXCEL Controlling Publisher help

Bacalhau75

New Member
Joined
Jul 9, 2014
Messages
12
Hello. I can usually figure out code when i'm stuck, but i've spent hours on this and need help.

I've been asked to help update publisher documents. I normally automate every task, but can't seem to automate this the way i want to.

My first issue is, after i find a certain phrase, i'm able to replace it. But if I have to add a new bullet in an outline, i cannot mimmic 'ENTER' which brings down the next letter and types out the text. Iv'e tried Vbtab, vbcr vbctrl (i can't get these to work period, and i never use this in my regular excel vba code. Not sure if it requires references set, i looked around but didn't see any. I usually use CHR(10) and CHR(13) if i have do to any type of carriage returns.

I gave up on the above for now and i need to confirm if certain words exist on a document, if not i need to close the doc and proceed to the next one.

This code below, i found on Microsoft help files and for some reason it only works the first time, afterwards '.FoundTextRange' is always set to NOTHING.

VBA Code:
Dim objFind as FindReplace 
Dim fFound as Boolean

Set objFind = ActiveDocument.Find
fFound = True

With objFind
.Clear
.FindText = "Important"
Do While fFound = True
fFound = .Execute
If Not .FoundTextRange Is Nothing Then
.FoundTextRange.Font.Bold = True
End If
Loop
End With

I tried changing the above code by removing the loop, and adding my own boolean statement. The first time (in the loop search) .FoundTextRange = "Thewords i'm searching", after that it's always 'Nothing'

Any help would be appreciated.
 

Some videos you may like

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Bacalhau75

New Member
Joined
Jul 9, 2014
Messages
12
I seem to have figured out the 2nd issue. I had to add the AppPub object to .Activedocument.find. This made it work. It's not listed on the MS web site.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,755
Messages
5,626,671
Members
416,200
Latest member
Pulsar3000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top