PDA

View Full Version : Open Publisher doc from Excel then edit



kilgour
06-10-2010, 08:11 AM
I am attempting to Open a saved publisher document from VBA code in Excel. What am I missing from the following code?

Dim pubApp As Publisher.Application
Dim pubDoc As Publisher.Document

Set pubApp = New Publisher.Application
Set pubDoc = pubApp.Documents.Add

pubApp.Open ("C:\Male.pub")


When I run this code, a new publisher window opens with a new document but does not load the required file. Could someone please let me know how I would do this?

Once the publisher document is open I am wanting to replace a text box already in it with some text from the excel file. Is this possible and if so could somebody please write some sample code that would do this?

Many thanks,

Paul

Cowlers
01-05-2011, 05:50 AM
Hi Kilgour,

I have recently started trying to work with Publisher from excel and I found that the following adaption to your code works:

Dim pubApp As Publisher.Application
Dim pubDoc As Publisher.Document

Set pubApp = New Publisher.Application
Set pubDoc = pubApp.Documents.Add.Application.Open("C:\Male.pub")

I know its not easy finding details of how to code this sort of operation,

I hope this helps!

Best regards,

Dan

Tinbendr
01-05-2011, 11:35 AM
AddpubDoc.ActiveWindow.Visible = True

David