USB printer

M

mcnews

i need to direct label printing to a local USB thermal printer.
what i am doing now is manually sharing the printer and executing a
NET USE \\computername\sharename /persistent:yes command.
this works fine.
but i'd like to do this from the MS Access label making application
that i created.

i would like to create the print share and map the printer with code.
i would need to be able to learn the printer name and computer name
via code as well.
i could shell to a batch file, but i haven't been able to figure out
how to create the share.
any tips?

tia,
mcnewsxp
 
D

Douglas J. Steele

Try:

Shell "NET USE \\computername\sharename /persistent:yes"

If there are spaces in the sharename, try

Shell "NET USE ""\\computername\sharename"" /persistent:yes"
 
M

mcnews

Try:

Shell "NET USE \\computername\sharename /persistent:yes"

If there are spaces in the sharename, try

Shell "NET USE ""\\computername\sharename"" /persistent:yes"

but how to create the sharename is my real question....?
 
D

Douglas J. Steele

Access doesn't have the ability to create shares. You must use Windows
functionality.

However, since the share only has to be created once, I can't see why you'd
need to do it from within Access.
 
M

mcnews

Access doesn't have the ability to create shares. You must use Windows
functionality.

However, since the share only has to be created once, I can't see why you'd
need to do it from within Access.

as i said, i have an Access label printing app that i am distributing.
i'd to control the print setup from the app if possible.
i created a script that works:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery("Select * from
Win32_Printer Where Network = FALSE")

For Each objPrinter In colInstalledPrinters
if objPrinter.Name = "hp deskjet 940c" then
objPrinter.Shared = True
objPrinter.ShareName = "hpdeskjet940c"
objPrinter.Put_
end if
Next

can we not use WMI from access like this?
 
D

Douglas J. Steele

That can be used essentially as-is in Access.

Here are the declarations you'll need at the top of the routine:

Dim objWMIService As Object
Dim colInstalledPrinters As Object
Dim objPrinter As Object
Dim strComputer As String


The point I was trying to make earlier is that you only need to run that
code once, so why bother putting it in your application?
 
M

mcnews

That can be used essentially as-is in Access.

Here are the declarations you'll need at the top of the routine:

Dim objWMIService As Object
Dim colInstalledPrinters As Object
Dim objPrinter As Object
Dim strComputer As String

The point I was trying to make earlier is that you only need to run that
code once, so why bother putting it in your application?

i tried that earlier, but i tried using early binding on the objects.
using generic object works.
thanks much!

i was thinking i would have an undo in case the users need to use LPT1
for something else....
 

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

Similar Threads


Top