MsgBox Print

ra_weiss

New Member
Joined
Oct 18, 2008
Messages
35
Oh, me-oh-my, what have I screwed up this time?

Code:
Dim MyFile As String


MsgResult = MsgBox("BOOM! You're done. Print Copies?", vbYesNo, "")
If MsgResult = vbYes Then
MyFile = Dir("C:\Documents and Settings\*i*.xls")
Do While MyFile <> ""
    Worksheet.PrintOut Filename:=MyFile ActivePrinter:="Canon MX320 series Printer"
    MyFile = Dir()
Loop
Else: End If

Why is "Worksheet.PrintOut Filename:=MyFile ActivePrinter:="Canon MX320 series Printer" rejected? Thanks.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Yes it does allow that.

Where did you read that it didn't?

I've just checked as well.
 
Upvote 0
Weird. When I add " MsgBox MyFile" following your code "MyFile = Dir("C:\Documents and Settings\~\*i*.xls")" it comes back with the found "equipment Sheet.xls", but when I click "ok" on that msgbox, continuing your code, I'm prompted with it cannot find "equipment sheets.xls".

What is wrong with this picture?
 
Last edited:
Upvote 0
It is there
JvhVjVq7


Do While MyFile <> ""
MsgBox MyFile, vbInformation

Returns "05-26-2011 Equipment Sheet.xls", at least, is found

"Set wbOpen = Workbooks.Open(MyFile)"
MsgBox wbOpen, vbInformation

Fails, indicating "05-26-2011 Equipment Sheet.xls" cannot be found. Check spelling, etc.
 
Upvote 0
Dir only returns the filename, so you need to add the path.
Code:
strPath = "C:\Documents and Settings\"
 
Set wbOpen = Workbooks.Open(strPath & MyFile)
Change the path/folder as needed.
 
Upvote 0
Weird. When I add " MsgBox MyFile" following your code "MyFile = Dir("C:\Documents and Settings\~\*i*.xls")" it comes back with the found "equipment Sheet.xls", but when I click "ok" on that msgbox, continuing your code, I'm prompted with it cannot find "equipment sheets.xls".

What is wrong with this picture?

Dir only returns the filename, so you need to add the path.
Code:
strPath = "C:\Documents and Settings\"
 
Set wbOpen = Workbooks.Open(strPath & MyFile)
Change the path/folder as needed.
You're a genius, my man. Next question:
Bonn9hQB

Seriously? Wow, I can't say if I'd be more at peace or scared out of my wits being your neighbor. Actually, I'd probably be drinking heavily in either case :)

Thank you again.
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,740
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top