Google Группы больше не поддерживают новые публикации и подписки в сети Usenet. Опубликованный ранее контент останется доступен.

How to print Word Doc or Excel file from Access

77 просмотров
Перейти к первому непрочитанному сообщению

SF

не прочитано,
12 мая 2009 г., 02:46:1412.05.2009
Hi,

I have saved the project dicuments (.Doc or .xls) in one of field of a
table. I have created a button where user can print the file but I don't
know how to code.

I have some ideas below

if right(field,3) = "doc" then
print word document base on the select path
else
print excel file
end if

Couls someone advice please.

SF


Wayne-I-M

не прочитано,
12 мая 2009 г., 03:37:0112.05.2009
Hi

There's a few mehtods - this is just one.

Create a new module

Function PrintDoc()
Dim WordObj As Object
Set WordObj = CreateObject("Word.Application")
WordObj.Documents.Open "Add path to Doc here"
WordObj.PrintOut Background:=False
WordObj.Quit
Set WordObj = Nothing
End Function

'Change Add path to DOC here to the real path to the DOC'

On a form add a button. Put this OnClick

Private Sub ButtonName_Click()
Call PrintDoc
End Sub

'Change ButtonName to what is really is'

OIf course in your case you would add this to the "if" - something like this

if right(field,3) = "doc" then

Call PrintDoc
else
Call PrintExcel
end if

Do the same for the excel file (but change wordobj and createobject)

Not sure what you mean by right(field,3) but you must ??


HtH

--
Wayne
Manchester, England.

Wayne-I-M

не прочитано,
12 мая 2009 г., 03:39:0112.05.2009
ooops just though - and reread ??

As you have a number of paths you will need to declare the path as a
variable - link this (DIM) to your table field / form control

--
Wayne
Manchester, England.

SF

не прочитано,
12 мая 2009 г., 05:44:2012.05.2009
Thank you Wayne. the code work perfectly...

SF

"Wayne-I-M" <Way...@discussions.microsoft.com> wrote in message
news:7FAEFAC7-B63B-425E...@microsoft.com...

Albert D. Kallal

не прочитано,
12 мая 2009 г., 12:58:5212.05.2009
To print a word, excel, or even a pdf, you can use:


dim strDoc as string

strdoc = "some path name to doc, excel, or even pdf)

Then:

CreateObject("Shell.Application").Namespace(0).ParseName(strDoc).InvokeVerb
("&Print")

In fact, the above works pretty much with any file + application that
supports right clicking on the file and choosing print....


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOO...@msn.com


SF

не прочитано,
12 мая 2009 г., 20:41:4812.05.2009
Thank. This is the first "shell" that i have seen for the first time. Will
try it.

SF

"Albert D. Kallal" <PleaseNOOO...@msn.com> wrote in message
news:O0IbvLy0...@TK2MSFTNGP03.phx.gbl...

0 новых сообщений