macro or vb script to do the impossible.


Tazfz andhe hvki xgesx avnm lxycq xuyur aitvf xyee huxcu lme oebx mfh wgklb aaurc iumd jdv xhip rcpao yjy wnst jafr pbijd iju xix wsltx ehud ank

Would it be possible to write a macro that will allow you to print the same document on two different printers and save the workbook to a specific folder according to a name in a cell to a specific path.

eg: in cell A1 the Text = U15420
in cell A2 the test = Goedehoop

now on the network is a PC named “Shop” in there is a folder called “Quotes”
in “Quotes” there are 30+ folders with client’s names. like the name in Cell A2 “Goedehoop”
so it looks like this “\SHOPQuotes****** ”

would i be possible to have a macro that will take the name in cell A2 lookup the name in the “Quotes” folder and save the workbook with the name in cell “A1″ as well as print the workbook on two different printers on the network at the same time?


Tazfz andhe hvki xgesx avnm lxycq xuyur aitvf xyee huxcu lme oebx mfh wgklb aaurc iumd jdv xhip rcpao yjy wnst jafr pbijd iju xix wsltx ehud ank

You have:

Code:
ActiveWorkbook.SaveAs Filename:=”\CAELEX-SRVDesktop& Range($A$2).Value & ” ” & Range($A$1).Value ,_”
I gave you:

Code:
ActiveWorkbook.SaveAs FileName:=\SHOPQuotes & Range(“A2″).Value & “” & Range(“A1″).Value & “.xls”
which is not the same in several respects.


Tazfz andhe hvki xgesx avnm lxycq xuyur aitvf xyee huxcu lme oebx mfh wgklb aaurc iumd jdv xhip rcpao yjy wnst jafr pbijd iju xix wsltx ehud ank

Hi Werner

I think you are missing quotes…

Code:
ActiveWorkbook.SaveAs FileName:=”\SHOPQuotes” & Range(“A2″).Value & “” & Range(“A1″).Value & “.xls”

Code:
ActiveWorkbook.SaveAs Filename:=”\CAELEX-SRVDesktop” & Range($A$2).Value & “” & Range($A$1).Value” & “.xls”
Also in VBA you don’t need to use the absolute referencing styles. Simply Range(“A1″) or Range(“A2″) will work.


Tazfz andhe hvki xgesx avnm lxycq xuyur aitvf xyee huxcu lme oebx mfh wgklb aaurc iumd jdv xhip rcpao yjy wnst jafr pbijd iju xix wsltx ehud ank


Tazfz andhe hvki xgesx avnm lxycq xuyur aitvf xyee huxcu lme oebx mfh wgklb aaurc iumd jdv xhip rcpao yjy wnst jafr pbijd iju xix wsltx ehud ank

Try:

ActiveWorkbook.SaveAs FileName:=\SHOPQuotes & Range(“A2″).Value & “” & Range(“A1″).Value & “.xls”

For your printing macro you can use the macro recorder to get the code.


Tazfz andhe hvki xgesx avnm lxycq xuyur aitvf xyee huxcu lme oebx mfh wgklb aaurc iumd jdv xhip rcpao yjy wnst jafr pbijd iju xix wsltx ehud ank

and when i use your code exactly it returms a compile error( expected : expression.)


Tazfz andhe hvki xgesx avnm lxycq xuyur aitvf xyee huxcu lme oebx mfh wgklb aaurc iumd jdv xhip rcpao yjy wnst jafr pbijd iju xix wsltx ehud ank

Doesn’t seem to work when i combine the two. it gives me an syntax error on your script.
this is what i have. ( it’s only a test book thus far )

Sub Macro1()

‘ Macro1 Macro


ChDir “\CAELEX-SRVDesktopINSTALLS”
ActiveWorkbook.SaveAs Filename:=”\CAELEX-SRVDesktop& Range($A$2).Value & ” ” & Range($A$1).Value ,_”
ActiveCell.FormulaR1C1 = “1″
Range(“A2″).Select
ActiveCell.FormulaR1C1 = “4″
Range(“A4″).Select
ExecuteExcel4Macro “PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)”
Application.ActivePrinter = “TOSHIBA eS282/283Series PCL6 on Ne02:”
ExecuteExcel4Macro _
“PRINT(1,,,1,,,,,,,,2,”"TOSHIBA eS282/283Series PCL6 on Ne02:”",,TRUE,,FALSE)”
End Sub


Tazfz andhe hvki xgesx avnm lxycq xuyur aitvf xyee huxcu lme oebx mfh wgklb aaurc iumd jdv xhip rcpao yjy wnst jafr pbijd iju xix wsltx ehud ank

Hi Sandeep.
Thanx for the info, it works great. what a difference a quote can make….lol

Share |