.Net Automation Publisher.Application.Open strangeness

U

Uranthos

Within my .Net application I need to open a Publisher document and then print
it out to a PDF printer. So my code as below

<--snip-->
dim pubApp = New Microsoft.Office.Interop.Publisher.Application

dim pubDoc = Microsoft.Office.Interop.Publisher.Document

pubDoc = pubApp.Open(FileName:=InputFileName, ReadOnly:=False,
AddToRecentFiles:=False,
SaveChanges:=Interop.Publisher.PbSaveOptions.pbDoNotSaveChanges)
<--snip-->
This is where it fails regardless of what contents the file contains and the
only error that i am getting is 'Publisher cannot open the file'. Does anyone
know what could be causing this to happen I am using .Net 2003 Office 2003
with the PIA's as the bridge beteen the two.

Thanks in advance

Matthew White
 
T

Tony B

As you posted a while ago I doubt you'll still want to know, but if
anyone else is having similar problems here is the code I use to open a
publisher file in VB.NET:


Dim objPublisher As New Publisher.Application()
Dim objCalendar As Publisher.Document

objCalendar = objPublisher.Open(strCalendarFile, _
False, False,
Publisher.PbSaveOptions.pbDoNotSaveChanges)

The file I'm opening is in the variable strCalendarFile. The first False
is for "Open Read Only" and the second False is "Add To Recent Document
List".

So the above opens my file for writing without adding it to the list of
recent documents.

Also I guess I should point out that I used the following at the top of
the file:
Imports Microsoft.Office.Interop


HTH

Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top