Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Print files

Geek News

Print files
JT 11/19/2008 12:02:02 AM
This code will print only file;
CreateObject("Shell.Application").Namespace(0).ParseName("c:\Notes\Note1.snp").InvokeVerb ("&Print")

I am trying to print all snp files and i keep getting error message ("object
variable or With block variable not set"). What am i doing wrong?


Dim strPath As String
Dim strFilter As String

strPath = "c:\Notes\"
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)")

CreateObject("Shell.Application").Namespace(0).ParseName(strPath +
strFilter).InvokeVerb ("&Print")



Function ahtAddFilterItem(strFilter As String, _
strDescription As String, Optional varItem As Variant) As String

If IsMissing(varItem) Then varItem = "*.*"
ahtAddFilterItem = strFilter & _
strDescription & vbNullChar & _
varItem & vbNullChar
End Function

Re: Print files
"Stuart McCall" <smccall[ at ]myunrealbox.com> 11/19/2008 1:03:53 AM
"JT" <JT[ at ]discussions.microsoft.com> wrote in message
news:4A6955DE-1E58-4630-9BCC-02A45217D802[ at ]microsoft.com...
[Quoted Text]
> This code will print only file;
>
> CreateObject("Shell.Application").Namespace(0).ParseName("c:\Notes\Note1.snp").InvokeVerb
> ("&Print")
>
> I am trying to print all snp files and i keep getting error message
> ("object
> variable or With block variable not set"). What am i doing wrong?
>
>
> Dim strPath As String
> Dim strFilter As String
>
> strPath = "c:\Notes\"
> strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)")
>
> CreateObject("Shell.Application").Namespace(0).ParseName(strPath +
> strFilter).InvokeVerb ("&Print")
>
>
>
> Function ahtAddFilterItem(strFilter As String, _
> strDescription As String, Optional varItem As Variant) As String
>
> If IsMissing(varItem) Then varItem = "*.*"
> ahtAddFilterItem = strFilter & _
> strDescription & vbNullChar & _
> varItem & vbNullChar
> End Function
>

Although I'm unfamiliar with this method, it looks to me like this line:

strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)")

should be just:

strFilter = "*.snp"


Re: Print files
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_gmail.com> 11/19/2008 12:49:03 PM
You seem to be combining things that aren't intended to be combined!

The function ahtAddFilterItem appears to be the function from
http://www.mvps.org/access/api/api0001.htm at "The Access Web". It's
intended to be used with the rest of the code on that page, which is how to
invoke the standard Windows File Open or File Save dialogues. On the other
hand, the ParseName method is intended to create and returns a FolderItem
object that represents a specified item. I do not believe you can use
wildcards with it.

Try:

Dim strPath As String
Dim strFile As String

strPath = "c:\Notes\"
strFile = Dir(strPath & "*.snp")
Do While Len(strFile) > 0
CreateObject("Shell.Application").Namespace(0).ParseName(strPath &
strFile).InvokeVerb ("&Print")
strFile = Dir()
Loop

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"JT" <JT[ at ]discussions.microsoft.com> wrote in message
news:4A6955DE-1E58-4630-9BCC-02A45217D802[ at ]microsoft.com...
[Quoted Text]
> This code will print only file;
>
> CreateObject("Shell.Application").Namespace(0).ParseName("c:\Notes\Note1.snp").InvokeVerb
> ("&Print")
>
> I am trying to print all snp files and i keep getting error message
> ("object
> variable or With block variable not set"). What am i doing wrong?
>
>
> Dim strPath As String
> Dim strFilter As String
>
> strPath = "c:\Notes\"
> strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)")
>
> CreateObject("Shell.Application").Namespace(0).ParseName(strPath +
> strFilter).InvokeVerb ("&Print")
>
>
>
> Function ahtAddFilterItem(strFilter As String, _
> strDescription As String, Optional varItem As Variant) As String
>
> If IsMissing(varItem) Then varItem = "*.*"
> ahtAddFilterItem = strFilter & _
> strDescription & vbNullChar & _
> varItem & vbNullChar
> End Function
>


Re: Print files - PLEASE HELP
JT 11/19/2008 5:46:09 PM
Thank you but when i click on button the print window will pop up. Sense i
have 100 and more snp files in my folder, I have to click 100 times and more
on 'Print' button. How can i avoid that??? Thank you

Private Sub Command10_Click()
On Error GoTo Command10_Click_Error
Dim strPath As String
Dim strFilter As String

strPath = "C:\Notes\"
strFile = Dir(strPath & "*.snp")

Do While Len(strFile) > 0
CreateObject("Shell.Application").Namespace(0).ParseName(strPath &
strFile).InvokeVerb ("&Print")
strFile = Dir()
Loop

Command10_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ")"
End Sub ---------------------------------------------------------------------------------

"Douglas J. Steele" wrote:

[Quoted Text]
> You seem to be combining things that aren't intended to be combined!
>
> The function ahtAddFilterItem appears to be the function from
> http://www.mvps.org/access/api/api0001.htm at "The Access Web". It's
> intended to be used with the rest of the code on that page, which is how to
> invoke the standard Windows File Open or File Save dialogues. On the other
> hand, the ParseName method is intended to create and returns a FolderItem
> object that represents a specified item. I do not believe you can use
> wildcards with it.
>
> Try:
>
> Dim strPath As String
> Dim strFile As String
>
> strPath = "c:\Notes\"
> strFile = Dir(strPath & "*.snp")
> Do While Len(strFile) > 0
> CreateObject("Shell.Application").Namespace(0).ParseName(strPath &
> strFile).InvokeVerb ("&Print")
> strFile = Dir()
> Loop
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "JT" <JT[ at ]discussions.microsoft.com> wrote in message
> news:4A6955DE-1E58-4630-9BCC-02A45217D802[ at ]microsoft.com...
> > This code will print only file;
> >
> > CreateObject("Shell.Application").Namespace(0).ParseName("c:\Notes\Note1.snp").InvokeVerb
> > ("&Print")
> >
> > I am trying to print all snp files and i keep getting error message
> > ("object
> > variable or With block variable not set"). What am i doing wrong?
> >
> >
> > Dim strPath As String
> > Dim strFilter As String
> >
> > strPath = "c:\Notes\"
> > strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)")
> >
> > CreateObject("Shell.Application").Namespace(0).ParseName(strPath +
> > strFilter).InvokeVerb ("&Print")
> >
> >
> >
> > Function ahtAddFilterItem(strFilter As String, _
> > strDescription As String, Optional varItem As Variant) As String
> >
> > If IsMissing(varItem) Then varItem = "*.*"
> > ahtAddFilterItem = strFilter & _
> > strDescription & vbNullChar & _
> > varItem & vbNullChar
> > End Function
> >
>
>
>
Re: Print files - PLEASE HELP
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_gmail.com> 11/19/2008 6:02:37 PM
If invoking the Print verb causes a dialog to appear, I don't think there's
anything you can do.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"JT" <JT[ at ]discussions.microsoft.com> wrote in message
news:04024162-2099-45D5-B3EE-62C0951E506A[ at ]microsoft.com...
[Quoted Text]
> Thank you but when i click on button the print window will pop up. Sense i
> have 100 and more snp files in my folder, I have to click 100 times and
> more
> on 'Print' button. How can i avoid that??? Thank you
>
> Private Sub Command10_Click()
> On Error GoTo Command10_Click_Error
> Dim strPath As String
> Dim strFilter As String
>
> strPath = "C:\Notes\"
> strFile = Dir(strPath & "*.snp")
>
> Do While Len(strFile) > 0
> CreateObject("Shell.Application").Namespace(0).ParseName(strPath &
> strFile).InvokeVerb ("&Print")
> strFile = Dir()
> Loop
>
> Command10_Click_Error:
> MsgBox "Error " & Err.Number & " (" & Err.Description & ")"
> End Sub
> ---------------------------------------------------------------------------------
>
> "Douglas J. Steele" wrote:
>
>> You seem to be combining things that aren't intended to be combined!
>>
>> The function ahtAddFilterItem appears to be the function from
>> http://www.mvps.org/access/api/api0001.htm at "The Access Web". It's
>> intended to be used with the rest of the code on that page, which is how
>> to
>> invoke the standard Windows File Open or File Save dialogues. On the
>> other
>> hand, the ParseName method is intended to create and returns a FolderItem
>> object that represents a specified item. I do not believe you can use
>> wildcards with it.
>>
>> Try:
>>
>> Dim strPath As String
>> Dim strFile As String
>>
>> strPath = "c:\Notes\"
>> strFile = Dir(strPath & "*.snp")
>> Do While Len(strFile) > 0
>> CreateObject("Shell.Application").Namespace(0).ParseName(strPath &
>> strFile).InvokeVerb ("&Print")
>> strFile = Dir()
>> Loop
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>>
>> "JT" <JT[ at ]discussions.microsoft.com> wrote in message
>> news:4A6955DE-1E58-4630-9BCC-02A45217D802[ at ]microsoft.com...
>> > This code will print only file;
>> >
>> > CreateObject("Shell.Application").Namespace(0).ParseName("c:\Notes\Note1.snp").InvokeVerb
>> > ("&Print")
>> >
>> > I am trying to print all snp files and i keep getting error message
>> > ("object
>> > variable or With block variable not set"). What am i doing wrong?
>> >
>> >
>> > Dim strPath As String
>> > Dim strFilter As String
>> >
>> > strPath = "c:\Notes\"
>> > strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)")
>> >
>> > CreateObject("Shell.Application").Namespace(0).ParseName(strPath +
>> > strFilter).InvokeVerb ("&Print")
>> >
>> >
>> >
>> > Function ahtAddFilterItem(strFilter As String, _
>> > strDescription As String, Optional varItem As Variant) As String
>> >
>> > If IsMissing(varItem) Then varItem = "*.*"
>> > ahtAddFilterItem = strFilter & _
>> > strDescription & vbNullChar & _
>> > varItem & vbNullChar
>> > End Function
>> >
>>
>>
>>


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net