Open pulisher from Access

G

gdonald20

Hi

I am aware that you can open excel and word from access and reference
documents to be printed.

Does the same function exist for Publisher and if so how do i go about
opening it and print a document and then closing it again.

I am using Access 2000 on windows 2000 if that's of any relevance.

Thanks in advance for any help

Gillian
 
D

Douglas J Steele

If all you want to do is print the document from Access (as opposed to, say,
getting text out of it or updating it), see whether my January, 2005 "Access
Answers" column in Pinnacle Publication's "Smart Access" helps. While it
doesn't specifically talk about Publisher, it does give generic details
about how to do this.

You can download the column (and sample database) for free at
http://www.accessmvp.com/djsteele/SmartAccess.html
 
G

gdonald20

Hi

Thanks for your reply but it doesn't really solve the whole problem. I can
find any reference to publisher in the references library and i can find no
information anywhere about Access performing this function with Publisher.

I just thought it would be strange that you can open and print any other
office product from inside access and not publisher.

Gillian
 
D

Douglas J. Steele

If there's no reference to Publisher in the list of available References,
that implies to me that Publisher isn't installed on that machine, in which
case you're not going to be able to print Publisher files on that machine.
(FWIW, the reference should be something like Microsoft Publisher n.0 Object
Model)

I know nothing at all about Publisher, so all this is speculation, but when
I went into Windows Explorer, selected Tools | Folder Options from the menu
bar, selected the File Types tab, scrolled through until I found the .pub
extension, selected the Advanced button, found the Print option and clicked
on Edit, I got the following in the "Application used to perform action"
box:

"C:\Program Files\Microsoft Office.11\OFFICE11\MSPUB.EXE" /p %1

That means that if you're got the full path to your Publisher file stored in
a variable strFile, something like the following should work:

Dim strShell As String

strShell = Chr$(34) & _
"C:\Program Files\Microsoft Office.11\OFFICE11\MSPUB.EXE" & _
Chr$(34) & " /p " & Chr$(34) & strFile & Chr$(34)
Shell strShell, vbHide
 
B

Brendan Reynolds

The following works for me, but only after setting the reference to the
publisher object library (Microsoft Publisher 11 Object Library). As Doug
says, if the library doesn't appear in the references dialog box, that would
seem to imply that Publisher is not installed on that PC, in which case this
won't work.

Public Sub PrintPub()

Dim app As Publisher.Application
Dim doc As Publisher.Document

Set app = New Publisher.Application
app.Open "c:\usenet\test.pub"
Set doc = app.ActiveDocument
doc.PrintOut
doc.Close
app.Quit

End Sub
 
G

gdonald20

Hi

Thanks for your further help i shall go away and try the things you
suggested. The only small problem i can think of is caused by the fact that i
definately have publisher on my computer i used it to design the document i
want to print but still there is an object reference for it.

Hoepfully your code will resovle the issue.

Thanks
 
G

gdonald20

Hi again

That code works perfectly and it now open publisher and prints the document.

I have one other small question. Is there any way to stop publisher opening
over the top of access showing the print progress before switching back to
access. I realise that it has to open but is there a way i can force access
to always be the front program if that makes sense.

Thanks
 
D

Douglas J. Steele

Did you include the vbHide parameter in your call to Shell? I would have
thought that that would have hidden Publisher.
 
G

gdonald20

Hi

In reply to both posts Douglas first:

I put the vbhide command in my code and it doesn't appear to hide anything,
had to slightly edit you code as i'm using office 2000 so the command string
differs slightly.

Brendan: This might seem enitrely illogical, it certainly doesn't make sense
to me but i most definately have publisher on my computer i used it to create
the document but i still don't get a reference to it in the access vb. That
being said the code that Douglas showed works perfectly apart from hiding
publisher.

Thanks to both of you
 
B

Brendan Reynolds

You mention you're using Office 2000 - I'm using Office 2003, which may
explain the difference. I don't remember which version of Publisher first
exposed an object model - perhaps your version doesn't.
 

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