i'm not sure what an OPC links is.
Do you have the value in a cell changing, and you want to print a page when the value in a specific cell changes?
which cell address and what is the sheet name it is in?
to use this macro, copy and paste this vba code into the sheet1 object using your vba editor, On windows I believe the keyboard shortcut to open the vba editor is Alt F11, otherwise you would have to get to it through the developer toolbar. Important this code must go in the Sheet1 section, when you first open the editor the workbook object will be selected, you will see a list of objects on the left window, you have to double click sheet1, to get to its area.
Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub Else Application.EnableEvents = False If Target.Value = "1" Then Me.PrintOut From:=1, To:=1 End If
Application.EnableEvents = True End IfEnd Sub
let me know if you have any questions, problems, or concerns
PLEASE DON'T FORGET TO RATE SO I AM PAID FOR MY TIME
IT WILL NOT COST ANYTHING ADDITIONAL BEYOND THE VALUE OF YOUR QUESTION
TO RATE, CLICK THE STARS AT THE TOP OF YOUR SCREEN
Do not rate negatively, instead continue the conversation with me so I can address any of your concerns
if you have any questions in the future you can visit my profile
and ask a question right in my box,
also you can put "PC Guy only" in your question title if you want to get to me.
works for me without error.
try changing the value in the cell directly to a 1 and see if it works without the link.
Then try again with the link
sounds to me like its a problem with your PLC code whatever that is, then. If the value changes then immediately changes back then I think excel is just not picking up on that. Is this an external program that is changing the cell value, or is it from another macro.
see the Worksheet_Change event will fire if the specified cell value changes, but I do not know how many milliseconds it takes for that to fire.
I think what I am asking is your code, is that also in VBA and is it in the same workbook?
link doesn't matter if the value is changing.
What is your other code, rather than triggering a cell change.
I would just add
Me.PrintOut From:=1, To:=1
directly to the code that changes the cell value.
instead of a worksheet change event.
so your code
range("A1").value = blahblah
rest of your code
ActiveWorkbook.Sheets("Sheet1").PrintOut From:=1, To:=1
if you want to get technical, incase you are working with multiple worksheets, and you want to trigger the print regardless of which worksheet is active
i need to see what is going on, do you want to set up a remote session.
I'm not exactly sure what is triggering the cell value to change without seeing it.
Can you remote desktop into that machine on your own network?
And The links wouldn't work for me unless they are online somewhere.
you say if you change the cell value to a 1, the macro triggers and it runs. But how else is the value of the cell changing.
what exactly are you doing to trigger the change?
yes so what is changing is it the hyperlink or is the the cell value or the formula?
a hyperlinks text property and the cell value are one and the same.
What I am still not clear on is exactly what is triggering the cell value to change.
You said you click the hyperlink in the cell and the value of the cell changes.
no i'm saying how do you intend to trigger the event how does the value in the cell change?
i'm sorry, dont know what I can do to help you any further. Since the cell value isn't exactly changing in excel, I guess that is why it wont trigger.
one more thing I thought of, sometimes when excel generates an error message, it kills any events, so maybe that is why it wasn't working. Try saving the sheet with my original macro, close excel and reboot the computer. Then open the file again. Remember you may need to activate macros to make it work. Then let me know what happens.
Sorry but this just occured to me