Hi,
I have searched the whole internet and i couldn't find anything that matches my needs. I hope someone here can help me out.
At work we make programs for CNC machines. Each program is saved the following: a letter (depends on machine), then 1,2 or 3(occur all 3 for every program), then the program number ( it can be 2-5 digits long, the digits between are zero's ).
For example program 20 for machine N is saved as : N1000020 & N2000020 & N3000020.
I am making an excel file where you can choose the machine, fill in the program number. Then with this data he should open all three of the files, make a selection till the word "END" is found, then print this selection and close the files again.
I have the following. This code will open print and close the needed files. the only thing I can't figure out is how to print the selection instead of the whole document. The selection I wan't to print is from the beginning untill the word "END"
Does someone know how to do this, or at least can help me going???
If my question is not clear, don't hesitate to ask
my code:
I have searched the whole internet and i couldn't find anything that matches my needs. I hope someone here can help me out.
At work we make programs for CNC machines. Each program is saved the following: a letter (depends on machine), then 1,2 or 3(occur all 3 for every program), then the program number ( it can be 2-5 digits long, the digits between are zero's ).
For example program 20 for machine N is saved as : N1000020 & N2000020 & N3000020.
I am making an excel file where you can choose the machine, fill in the program number. Then with this data he should open all three of the files, make a selection till the word "END" is found, then print this selection and close the files again.
I have the following. This code will open print and close the needed files. the only thing I can't figure out is how to print the selection instead of the whole document. The selection I wan't to print is from the beginning untill the word "END"
Does someone know how to do this, or at least can help me going???
If my question is not clear, don't hesitate to ask
my code:
Code:
[COLOR=#101094]Private[/COLOR][COLOR=#303336] [/COLOR][COLOR=#101094]Sub[/COLOR][COLOR=#303336] OKbutton_Click[/COLOR][COLOR=#303336]()[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]Dim[/COLOR][COLOR=#303336] iLetter [/COLOR][COLOR=#101094]As[/COLOR][COLOR=#303336] [/COLOR][COLOR=#101094] Long[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]Dim[/COLOR][COLOR=#303336] letter [/COLOR][COLOR=#101094]As[/COLOR][COLOR=#303336] [/COLOR][COLOR=#101094] String[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]Dim[/COLOR][COLOR=#303336] objdoc [/COLOR][COLOR=#101094]As[/COLOR][COLOR=#303336] [/COLOR][COLOR=#101094] Object[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]Select[/COLOR][COLOR=#303336] [/COLOR][COLOR=#101094]Case[/COLOR][COLOR=#303336] machinebox[/COLOR][COLOR=#303336].[/COLOR][COLOR=#303336]Value
[/COLOR][COLOR=#101094]Case[/COLOR][COLOR=#303336] [/COLOR][COLOR=#7D2727]"CTX510"[/COLOR][COLOR=#303336]
letter [/COLOR][COLOR=#303336]=[/COLOR][COLOR=#303336] [/COLOR][COLOR=#7D2727]"C"[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]Case[/COLOR][COLOR=#303336] [/COLOR][COLOR=#7D2727]"Lu25"[/COLOR][COLOR=#303336]
letter [/COLOR][COLOR=#303336]=[/COLOR][COLOR=#303336] [/COLOR][COLOR=#7D2727]"F"[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]Case[/COLOR][COLOR=#303336] [/COLOR][COLOR=#7D2727]"LB45"[/COLOR][COLOR=#303336]
letter [/COLOR][COLOR=#303336]=[/COLOR][COLOR=#303336] [/COLOR][COLOR=#7D2727]"N"[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]End[/COLOR][COLOR=#303336] [/COLOR][COLOR=#101094]Select[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]With[/COLOR][COLOR=#303336] CreateObject[/COLOR][COLOR=#303336]([/COLOR][COLOR=#7D2727]"word.application"[/COLOR][COLOR=#303336])[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]For[/COLOR][COLOR=#303336] iLetter [/COLOR][COLOR=#303336]=[/COLOR][COLOR=#303336] [/COLOR][COLOR=#7D2727]1[/COLOR][COLOR=#303336] [/COLOR][COLOR=#101094]To[/COLOR][COLOR=#303336] [/COLOR][COLOR=#7D2727]3[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]Set[/COLOR][COLOR=#303336] objdoc [/COLOR][COLOR=#303336]=[/COLOR][COLOR=#303336] [/COLOR][COLOR=#303336].[/COLOR][COLOR=#303336]documents[/COLOR][COLOR=#303336].[/COLOR][COLOR=#303336]Open[/COLOR][COLOR=#303336]([/COLOR][COLOR=#7D2727]"\\path\Machine"[/COLOR][COLOR=#303336] [/COLOR][COLOR=#303336]&[/COLOR][COLOR=#303336] machinebox[/COLOR][COLOR=#303336].[/COLOR][COLOR=#303336]Value [/COLOR][COLOR=#303336]&[/COLOR][COLOR=#303336] [/COLOR][COLOR=#7D2727]""[/COLOR][COLOR=#303336] [/COLOR][COLOR=#303336]&[/COLOR][COLOR=#303336] letter [/COLOR][COLOR=#303336]&[/COLOR][COLOR=#303336] iLetter [/COLOR][COLOR=#303336]&[/COLOR][COLOR=#303336] Format[/COLOR][COLOR=#303336]([/COLOR][COLOR=#303336]programbox[/COLOR][COLOR=#303336],[/COLOR][COLOR=#303336] [/COLOR][COLOR=#7D2727]"000000"[/COLOR][COLOR=#303336])[/COLOR][COLOR=#303336] [/COLOR][COLOR=#303336]&[/COLOR][COLOR=#303336] [/COLOR][COLOR=#7D2727]".OPT"[/COLOR][COLOR=#303336])[/COLOR][COLOR=#303336]
objdoc[/COLOR][COLOR=#303336].[/COLOR][COLOR=#303336]PrintOut
objdoc[/COLOR][COLOR=#303336].[/COLOR][COLOR=#303336]Close [/COLOR][COLOR=#7D2727]False[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]Next[/COLOR][COLOR=#303336] iLetter
[/COLOR][COLOR=#101094]End[/COLOR][COLOR=#303336] [/COLOR][COLOR=#101094]With[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]End[/COLOR][COLOR=#303336] [/COLOR][COLOR=#101094]sub
[/COLOR]
Last edited by a moderator: