Adding all the digits,
\[1+2+3+4+5+6+7=28 \equiv 1 \; (mod \; 9)\]
, so \[A \equiv B \; (mod \; 9)\]
. Suppose \[B=nA\]
then \[n\]
must be equal to 1 modulo 9, so must be equal to one of 1, 10, 19,...But
\[\frac{B}{A} \le \frac{7654321}{1234567}=6.2 \lt 7\]
so \[n=1\]
and \[A=B\]
.