57K, Fred, and 777TRUTH have all given good advice here. See... the thing to remember when using any of the slower burning powders for a particular caliber is that they need enough pressure to operate correctly or you're gonna get very wide standard deviation numbers or extreme spread (in feet per second of velocity) numbers from the load. It just won't "light up" completely without a way to generate pretty good internal pressure for the caliber. That means that heavier bullets for the caliber and loadings in the upper 1/2 or more for the bullet weight are required to get the best effeciency from the slower powder.
So with the combination you are proposing of AA7 and the 165grn bullet in .40, as noted by the other esteemed members, you have to contend with two things.
1) You gotta run the gun! You need enough power to operate a semi-auto pistol with any reloading choice while staying within the safe limits of course.
2) You have to create enough pressure to make the load viable. In this case, as 777TRUTH pointed out, with that bullet, perhaps another powder would be a better choice, but AA7 has been used to good effect in this caliber.
If all you have is AA7, and 165grn bullets, you can certainly make it work, but hopefully you have a chronograph available to you to see when your experiments cross over into a range where your extreme spreads are reduced to a minimum and so your standard deviation numbers fall to acceptable limits like the low double digits (20 or below I would think for SD). This will indicate that the powder is burning more completely and consistently and will make for a safer load too. That is why there are "minimum" as well as "maximum" loadings for a particular combination as powders get squirrely when they operate outside their design limits.
I, Procrastitron will destroy evil... eventually!
Strangely, a lot of folks who do not believe in evolutionary Darwinism seem to believe in social Darwinism... go figure!
Let's add this: Congress shall make no law which limits the type, caliber, capacity, or rate of fire of any arms the People have or want to have.