[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

RE: MS-DOS commands from within Visual Basic Version 6.3

freddy

12/18/2006 5:20:00 PM

Tom, the command I used successfully as a test was: Shell ("print
c:\tmp\*.rpt")
The part I want to be a variable is the print parameter (or file name),
which I have stored in previous lines of Visual Basic code.

"Tom Ogilvy" wrote:

> show the command you used and the part you want to be variable.
>
> The argument to shell is a string, so you can concatenate a variable value
> into the string
>
> --
> Regards,
> Tom Ogilvy
>
>
> "Freddy" wrote:
>
> > I tested your response successfully. Along these lines, can I pass a variable
> > within the Shell command?
> >
> > "Martin" wrote:
> >
> > > Don't know about VB but in VBA you can use Shell("path and executable")
> > >
> > > "Freddy" wrote:
> > >
> > > > How do I run an MS-DOS command, specifically "print" an external file, from
> > > > within Visual Basic Version 6.3? Does anyone have sample code?
7 Answers

freddy

12/18/2006 6:03:00 PM

0

Jim, this is what I am testing now:

Sub test()
Application.Dialogs(xlDialogOpen).Show
RFileType = "*.rpt"
Dim workfiles1 As String
workfiles1 = Dir(RFileType)
While workfiles1 <> ""
Shell ("print workfiles1") 'THIS IS WHERE I WANT THE PRINT VARIABLE
TO GO
workfiles1 = Dir()
If workfiles1 = "" Then
End
End If
Wend
End Sub




"Jim Thomlinson" wrote:

> Something like this???
>
> dim str as string
>
> str = "c:\tmp\"
> Shell ("print " & str & "*.rpt")
>
> --
> HTH...
>
> Jim Thomlinson
>
>
> "Freddy" wrote:
>
> > Tom, the command I used successfully as a test was: Shell ("print
> > c:\tmp\*.rpt")
> > The part I want to be a variable is the print parameter (or file name),
> > which I have stored in previous lines of Visual Basic code.
> >
> > "Tom Ogilvy" wrote:
> >
> > > show the command you used and the part you want to be variable.
> > >
> > > The argument to shell is a string, so you can concatenate a variable value
> > > into the string
> > >
> > > --
> > > Regards,
> > > Tom Ogilvy
> > >
> > >
> > > "Freddy" wrote:
> > >
> > > > I tested your response successfully. Along these lines, can I pass a variable
> > > > within the Shell command?
> > > >
> > > > "Martin" wrote:
> > > >
> > > > > Don't know about VB but in VBA you can use Shell("path and executable")
> > > > >
> > > > > "Freddy" wrote:
> > > > >
> > > > > > How do I run an MS-DOS command, specifically "print" an external file, from
> > > > > > within Visual Basic Version 6.3? Does anyone have sample code?

Jim Thomlinson

12/18/2006 6:46:00 PM

0

What exactly is the code intended to do? I am guessing that it is supposed to
print all of the report files in a directory specified by the user... but
that's just a guess...
--
HTH...

Jim Thomlinson


"Freddy" wrote:

> Jim, this is what I am testing now:
>
> Sub test()
> Application.Dialogs(xlDialogOpen).Show
> RFileType = "*.rpt"
> Dim workfiles1 As String
> workfiles1 = Dir(RFileType)
> While workfiles1 <> ""
> Shell ("print workfiles1") 'THIS IS WHERE I WANT THE PRINT VARIABLE
> TO GO
> workfiles1 = Dir()
> If workfiles1 = "" Then
> End
> End If
> Wend
> End Sub
>
>
>
>
> "Jim Thomlinson" wrote:
>
> > Something like this???
> >
> > dim str as string
> >
> > str = "c:\tmp\"
> > Shell ("print " & str & "*.rpt")
> >
> > --
> > HTH...
> >
> > Jim Thomlinson
> >
> >
> > "Freddy" wrote:
> >
> > > Tom, the command I used successfully as a test was: Shell ("print
> > > c:\tmp\*.rpt")
> > > The part I want to be a variable is the print parameter (or file name),
> > > which I have stored in previous lines of Visual Basic code.
> > >
> > > "Tom Ogilvy" wrote:
> > >
> > > > show the command you used and the part you want to be variable.
> > > >
> > > > The argument to shell is a string, so you can concatenate a variable value
> > > > into the string
> > > >
> > > > --
> > > > Regards,
> > > > Tom Ogilvy
> > > >
> > > >
> > > > "Freddy" wrote:
> > > >
> > > > > I tested your response successfully. Along these lines, can I pass a variable
> > > > > within the Shell command?
> > > > >
> > > > > "Martin" wrote:
> > > > >
> > > > > > Don't know about VB but in VBA you can use Shell("path and executable")
> > > > > >
> > > > > > "Freddy" wrote:
> > > > > >
> > > > > > > How do I run an MS-DOS command, specifically "print" an external file, from
> > > > > > > within Visual Basic Version 6.3? Does anyone have sample code?

freddy

12/18/2006 8:20:00 PM

0

The code I have already written runs a loop which opens a set of files
consisting of master xls workbook and several associated wk3 files which are
then used as input to the master xls workbook. In turn, the revised master
xls workbook is then printed and all open files are then closed then the loop
continues and opens another master xls spreadsheet and its associated wk3
files, etc. However, I do not want to close the application then print an
associated additional file (the extension being ".rpt") that has already been
created by another application. While my primary code is running variables
are assigned to the files being used. I'd like to take advantage of those
variables then print the associated ".rpt" file within VBA.


"Jim Thomlinson" wrote:

> What exactly is the code intended to do? I am guessing that it is supposed to
> print all of the report files in a directory specified by the user... but
> that's just a guess...
> --
> HTH...
>
> Jim Thomlinson
>
>
> "Freddy" wrote:
>
> > Jim, this is what I am testing now:
> >
> > Sub test()
> > Application.Dialogs(xlDialogOpen).Show
> > RFileType = "*.rpt"
> > Dim workfiles1 As String
> > workfiles1 = Dir(RFileType)
> > While workfiles1 <> ""
> > Shell ("print workfiles1") 'THIS IS WHERE I WANT THE PRINT VARIABLE
> > TO GO
> > workfiles1 = Dir()
> > If workfiles1 = "" Then
> > End
> > End If
> > Wend
> > End Sub
> >
> >
> >
> >
> > "Jim Thomlinson" wrote:
> >
> > > Something like this???
> > >
> > > dim str as string
> > >
> > > str = "c:\tmp\"
> > > Shell ("print " & str & "*.rpt")
> > >
> > > --
> > > HTH...
> > >
> > > Jim Thomlinson
> > >
> > >
> > > "Freddy" wrote:
> > >
> > > > Tom, the command I used successfully as a test was: Shell ("print
> > > > c:\tmp\*.rpt")
> > > > The part I want to be a variable is the print parameter (or file name),
> > > > which I have stored in previous lines of Visual Basic code.
> > > >
> > > > "Tom Ogilvy" wrote:
> > > >
> > > > > show the command you used and the part you want to be variable.
> > > > >
> > > > > The argument to shell is a string, so you can concatenate a variable value
> > > > > into the string
> > > > >
> > > > > --
> > > > > Regards,
> > > > > Tom Ogilvy
> > > > >
> > > > >
> > > > > "Freddy" wrote:
> > > > >
> > > > > > I tested your response successfully. Along these lines, can I pass a variable
> > > > > > within the Shell command?
> > > > > >
> > > > > > "Martin" wrote:
> > > > > >
> > > > > > > Don't know about VB but in VBA you can use Shell("path and executable")
> > > > > > >
> > > > > > > "Freddy" wrote:
> > > > > > >
> > > > > > > > How do I run an MS-DOS command, specifically "print" an external file, from
> > > > > > > > within Visual Basic Version 6.3? Does anyone have sample code?

Jon Peltier

12/18/2006 9:58:00 PM

0

Read a little bit about string manipulation. This line does what you want,
if you don't have to worry about the path:

Shell ("print " & workfiles1)

If you need to worry about the path, then you have to get it (probably using
CurDir) and insert it into the line above.

I'd probably use GetOpenFileName with multiple selection enabled and using a
filter for *.rpt, then process the nice array of the selected file names
that is returned.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://Pelti...
_______


"Freddy" <Freddy@discussions.microsoft.com> wrote in message
news:3BD3A861-3339-466D-9D46-FC22F71EAA65@microsoft.com...
> Jim, this is what I am testing now:
>
> Sub test()
> Application.Dialogs(xlDialogOpen).Show
> RFileType = "*.rpt"
> Dim workfiles1 As String
> workfiles1 = Dir(RFileType)
> While workfiles1 <> ""
> Shell ("print workfiles1") 'THIS IS WHERE I WANT THE PRINT VARIABLE
> TO GO
> workfiles1 = Dir()
> If workfiles1 = "" Then
> End
> End If
> Wend
> End Sub
>
>
>
>
> "Jim Thomlinson" wrote:
>
>> Something like this???
>>
>> dim str as string
>>
>> str = "c:\tmp\"
>> Shell ("print " & str & "*.rpt")
>>
>> --
>> HTH...
>>
>> Jim Thomlinson
>>
>>
>> "Freddy" wrote:
>>
>> > Tom, the command I used successfully as a test was: Shell ("print
>> > c:\tmp\*.rpt")
>> > The part I want to be a variable is the print parameter (or file name),
>> > which I have stored in previous lines of Visual Basic code.
>> >
>> > "Tom Ogilvy" wrote:
>> >
>> > > show the command you used and the part you want to be variable.
>> > >
>> > > The argument to shell is a string, so you can concatenate a variable
>> > > value
>> > > into the string
>> > >
>> > > --
>> > > Regards,
>> > > Tom Ogilvy
>> > >
>> > >
>> > > "Freddy" wrote:
>> > >
>> > > > I tested your response successfully. Along these lines, can I pass
>> > > > a variable
>> > > > within the Shell command?
>> > > >
>> > > > "Martin" wrote:
>> > > >
>> > > > > Don't know about VB but in VBA you can use Shell("path and
>> > > > > executable")
>> > > > >
>> > > > > "Freddy" wrote:
>> > > > >
>> > > > > > How do I run an MS-DOS command, specifically "print" an
>> > > > > > external file, from
>> > > > > > within Visual Basic Version 6.3? Does anyone have sample code?


freddy

12/19/2006 1:18:00 PM

0

I implemented your suggestion successfully. However, a side issue has
resulted during printing. Although I receive my one page printout, it is
followed by a blank trailer page. How can I eliminate the trailer page?

"Jon Peltier" wrote:

> Read a little bit about string manipulation. This line does what you want,
> if you don't have to worry about the path:
>
> Shell ("print " & workfiles1)
>
> If you need to worry about the path, then you have to get it (probably using
> CurDir) and insert it into the line above.
>
> I'd probably use GetOpenFileName with multiple selection enabled and using a
> filter for *.rpt, then process the nice array of the selected file names
> that is returned.
>
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Tutorials and Custom Solutions
> http://Pelti...
> _______
>
>
> "Freddy" <Freddy@discussions.microsoft.com> wrote in message
> news:3BD3A861-3339-466D-9D46-FC22F71EAA65@microsoft.com...
> > Jim, this is what I am testing now:
> >
> > Sub test()
> > Application.Dialogs(xlDialogOpen).Show
> > RFileType = "*.rpt"
> > Dim workfiles1 As String
> > workfiles1 = Dir(RFileType)
> > While workfiles1 <> ""
> > Shell ("print workfiles1") 'THIS IS WHERE I WANT THE PRINT VARIABLE
> > TO GO
> > workfiles1 = Dir()
> > If workfiles1 = "" Then
> > End
> > End If
> > Wend
> > End Sub
> >
> >
> >
> >
> > "Jim Thomlinson" wrote:
> >
> >> Something like this???
> >>
> >> dim str as string
> >>
> >> str = "c:\tmp\"
> >> Shell ("print " & str & "*.rpt")
> >>
> >> --
> >> HTH...
> >>
> >> Jim Thomlinson
> >>
> >>
> >> "Freddy" wrote:
> >>
> >> > Tom, the command I used successfully as a test was: Shell ("print
> >> > c:\tmp\*.rpt")
> >> > The part I want to be a variable is the print parameter (or file name),
> >> > which I have stored in previous lines of Visual Basic code.
> >> >
> >> > "Tom Ogilvy" wrote:
> >> >
> >> > > show the command you used and the part you want to be variable.
> >> > >
> >> > > The argument to shell is a string, so you can concatenate a variable
> >> > > value
> >> > > into the string
> >> > >
> >> > > --
> >> > > Regards,
> >> > > Tom Ogilvy
> >> > >
> >> > >
> >> > > "Freddy" wrote:
> >> > >
> >> > > > I tested your response successfully. Along these lines, can I pass
> >> > > > a variable
> >> > > > within the Shell command?
> >> > > >
> >> > > > "Martin" wrote:
> >> > > >
> >> > > > > Don't know about VB but in VBA you can use Shell("path and
> >> > > > > executable")
> >> > > > >
> >> > > > > "Freddy" wrote:
> >> > > > >
> >> > > > > > How do I run an MS-DOS command, specifically "print" an
> >> > > > > > external file, from
> >> > > > > > within Visual Basic Version 6.3? Does anyone have sample code?
>
>
>

Jon Peltier

12/19/2006 1:33:00 PM

0

This might be a printer issue, a separator page. It may not be readily
changed with VBA through a print setup dialog, and I doubt Shell will touch
it. See if you can set it manually.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://Pelti...
_______


"Freddy" <Freddy@discussions.microsoft.com> wrote in message
news:068DB8D0-34E0-43A2-9BE8-F8F254B3B987@microsoft.com...
>I implemented your suggestion successfully. However, a side issue has
> resulted during printing. Although I receive my one page printout, it is
> followed by a blank trailer page. How can I eliminate the trailer page?
>
> "Jon Peltier" wrote:
>
>> Read a little bit about string manipulation. This line does what you
>> want,
>> if you don't have to worry about the path:
>>
>> Shell ("print " & workfiles1)
>>
>> If you need to worry about the path, then you have to get it (probably
>> using
>> CurDir) and insert it into the line above.
>>
>> I'd probably use GetOpenFileName with multiple selection enabled and
>> using a
>> filter for *.rpt, then process the nice array of the selected file names
>> that is returned.
>>
>> - Jon
>> -------
>> Jon Peltier, Microsoft Excel MVP
>> Tutorials and Custom Solutions
>> http://Pelti...
>> _______
>>
>>
>> "Freddy" <Freddy@discussions.microsoft.com> wrote in message
>> news:3BD3A861-3339-466D-9D46-FC22F71EAA65@microsoft.com...
>> > Jim, this is what I am testing now:
>> >
>> > Sub test()
>> > Application.Dialogs(xlDialogOpen).Show
>> > RFileType = "*.rpt"
>> > Dim workfiles1 As String
>> > workfiles1 = Dir(RFileType)
>> > While workfiles1 <> ""
>> > Shell ("print workfiles1") 'THIS IS WHERE I WANT THE PRINT
>> > VARIABLE
>> > TO GO
>> > workfiles1 = Dir()
>> > If workfiles1 = "" Then
>> > End
>> > End If
>> > Wend
>> > End Sub
>> >
>> >
>> >
>> >
>> > "Jim Thomlinson" wrote:
>> >
>> >> Something like this???
>> >>
>> >> dim str as string
>> >>
>> >> str = "c:\tmp\"
>> >> Shell ("print " & str & "*.rpt")
>> >>
>> >> --
>> >> HTH...
>> >>
>> >> Jim Thomlinson
>> >>
>> >>
>> >> "Freddy" wrote:
>> >>
>> >> > Tom, the command I used successfully as a test was: Shell ("print
>> >> > c:\tmp\*.rpt")
>> >> > The part I want to be a variable is the print parameter (or file
>> >> > name),
>> >> > which I have stored in previous lines of Visual Basic code.
>> >> >
>> >> > "Tom Ogilvy" wrote:
>> >> >
>> >> > > show the command you used and the part you want to be variable.
>> >> > >
>> >> > > The argument to shell is a string, so you can concatenate a
>> >> > > variable
>> >> > > value
>> >> > > into the string
>> >> > >
>> >> > > --
>> >> > > Regards,
>> >> > > Tom Ogilvy
>> >> > >
>> >> > >
>> >> > > "Freddy" wrote:
>> >> > >
>> >> > > > I tested your response successfully. Along these lines, can I
>> >> > > > pass
>> >> > > > a variable
>> >> > > > within the Shell command?
>> >> > > >
>> >> > > > "Martin" wrote:
>> >> > > >
>> >> > > > > Don't know about VB but in VBA you can use Shell("path and
>> >> > > > > executable")
>> >> > > > >
>> >> > > > > "Freddy" wrote:
>> >> > > > >
>> >> > > > > > How do I run an MS-DOS command, specifically "print" an
>> >> > > > > > external file, from
>> >> > > > > > within Visual Basic Version 6.3? Does anyone have sample
>> >> > > > > > code?
>>
>>
>>


freddy

12/19/2006 2:03:00 PM

0

Thank you all for your assistance in resolving my issue. I am sure others
will arise.

"Jon Peltier" wrote:

> This might be a printer issue, a separator page. It may not be readily
> changed with VBA through a print setup dialog, and I doubt Shell will touch
> it. See if you can set it manually.
>
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Tutorials and Custom Solutions
> http://Pelti...
> _______
>
>
> "Freddy" <Freddy@discussions.microsoft.com> wrote in message
> news:068DB8D0-34E0-43A2-9BE8-F8F254B3B987@microsoft.com...
> >I implemented your suggestion successfully. However, a side issue has
> > resulted during printing. Although I receive my one page printout, it is
> > followed by a blank trailer page. How can I eliminate the trailer page?
> >
> > "Jon Peltier" wrote:
> >
> >> Read a little bit about string manipulation. This line does what you
> >> want,
> >> if you don't have to worry about the path:
> >>
> >> Shell ("print " & workfiles1)
> >>
> >> If you need to worry about the path, then you have to get it (probably
> >> using
> >> CurDir) and insert it into the line above.
> >>
> >> I'd probably use GetOpenFileName with multiple selection enabled and
> >> using a
> >> filter for *.rpt, then process the nice array of the selected file names
> >> that is returned.
> >>
> >> - Jon
> >> -------
> >> Jon Peltier, Microsoft Excel MVP
> >> Tutorials and Custom Solutions
> >> http://Pelti...
> >> _______
> >>
> >>
> >> "Freddy" <Freddy@discussions.microsoft.com> wrote in message
> >> news:3BD3A861-3339-466D-9D46-FC22F71EAA65@microsoft.com...
> >> > Jim, this is what I am testing now:
> >> >
> >> > Sub test()
> >> > Application.Dialogs(xlDialogOpen).Show
> >> > RFileType = "*.rpt"
> >> > Dim workfiles1 As String
> >> > workfiles1 = Dir(RFileType)
> >> > While workfiles1 <> ""
> >> > Shell ("print workfiles1") 'THIS IS WHERE I WANT THE PRINT
> >> > VARIABLE
> >> > TO GO
> >> > workfiles1 = Dir()
> >> > If workfiles1 = "" Then
> >> > End
> >> > End If
> >> > Wend
> >> > End Sub
> >> >
> >> >
> >> >
> >> >
> >> > "Jim Thomlinson" wrote:
> >> >
> >> >> Something like this???
> >> >>
> >> >> dim str as string
> >> >>
> >> >> str = "c:\tmp\"
> >> >> Shell ("print " & str & "*.rpt")
> >> >>
> >> >> --
> >> >> HTH...
> >> >>
> >> >> Jim Thomlinson
> >> >>
> >> >>
> >> >> "Freddy" wrote:
> >> >>
> >> >> > Tom, the command I used successfully as a test was: Shell ("print
> >> >> > c:\tmp\*.rpt")
> >> >> > The part I want to be a variable is the print parameter (or file
> >> >> > name),
> >> >> > which I have stored in previous lines of Visual Basic code.
> >> >> >
> >> >> > "Tom Ogilvy" wrote:
> >> >> >
> >> >> > > show the command you used and the part you want to be variable.
> >> >> > >
> >> >> > > The argument to shell is a string, so you can concatenate a
> >> >> > > variable
> >> >> > > value
> >> >> > > into the string
> >> >> > >
> >> >> > > --
> >> >> > > Regards,
> >> >> > > Tom Ogilvy
> >> >> > >
> >> >> > >
> >> >> > > "Freddy" wrote:
> >> >> > >
> >> >> > > > I tested your response successfully. Along these lines, can I
> >> >> > > > pass
> >> >> > > > a variable
> >> >> > > > within the Shell command?
> >> >> > > >
> >> >> > > > "Martin" wrote:
> >> >> > > >
> >> >> > > > > Don't know about VB but in VBA you can use Shell("path and
> >> >> > > > > executable")
> >> >> > > > >
> >> >> > > > > "Freddy" wrote:
> >> >> > > > >
> >> >> > > > > > How do I run an MS-DOS command, specifically "print" an
> >> >> > > > > > external file, from
> >> >> > > > > > within Visual Basic Version 6.3? Does anyone have sample
> >> >> > > > > > code?
> >>
> >>
> >>
>
>
>