What you do in one account is irrelevant to the tax treatment of other. We can largely treat the two sets of transactions separately. If you sell Stock A and then quickly buying it back within 30 days, it's known as a "wash sale". You won't be able to claim any losses from the sale (although the losses will be part of the cost basis), but as far as I know, you can use this tactic to effectively use part of the loss to offset the dividend payment. This will reset the clock as far as "long-term capital gains", however.
So for instance, suppose you buy a stock for $30, and it's now worth $28. It distributes $1 in dividends, and the stock price immediately goes down to $27 (dividends aren't free money; they come out of the stock price). Several years later, you sell it for $40.
Scenario 1: You hold onto the stock the whole time. You pay tax on the $1 dividend immediately, and then when you sell it for $40, you have a $30 tax basis, so you have to pay tax on the $10 profit.
Scenario 2: You sell just before the distribution, and buy right after. You now have a tax basis of $29 (you have a cost basis of $27 from buying it at $27, but your earlier $2 loss is also added to the cost basis). When you sell the stock for $40, you have to pay tax on the $11 difference.
So in both cases, the $1 dividends is eventually taxable income, it's just a question of when. If you think you'll have a lower tax rate in the future, or it would currently be short-term capital gains but would be long-term gains later, or you think the stock won't ever recover (and you don't think you will ever have a capital gain that you can offset with this loss), then this plan may have value. You should consult a professional, however.